|
@@ -9,6 +9,7 @@ import (
|
|
|
"time"
|
|
|
|
|
|
"git.lattuga.net/boyska/circolog"
|
|
|
+ "git.lattuga.net/boyska/circolog/formatter"
|
|
|
"github.com/gorilla/websocket"
|
|
|
"gopkg.in/mcuadros/go-syslog.v2/format"
|
|
|
)
|
|
@@ -56,7 +57,7 @@ func parseParameters(r *http.Request) (circolog.ClientOptions, error) {
|
|
|
}
|
|
|
|
|
|
type renderOptions struct { // those are options relevant to the rendered (that is, the HTTP side of circologd)
|
|
|
- Format renderFormat
|
|
|
+ Format formatter.Format
|
|
|
}
|
|
|
|
|
|
func parseRenderParameters(r *http.Request) (renderOptions, error) {
|
|
@@ -70,11 +71,10 @@ func parseRenderParameters(r *http.Request) (renderOptions, error) {
|
|
|
if len(val) != 1 {
|
|
|
return opts, errors.New("Format repeated multiple times")
|
|
|
}
|
|
|
- format, err := parseRenderFormat(val[0])
|
|
|
+ err := opts.Format.Set(val[0])
|
|
|
if err != nil {
|
|
|
return opts, err
|
|
|
}
|
|
|
- opts.Format = format
|
|
|
}
|
|
|
return opts, nil
|
|
|
}
|
|
@@ -106,9 +106,10 @@ func getHTTPHandler(hub circolog.Hub) http.HandlerFunc {
|
|
|
hub.Register <- client
|
|
|
|
|
|
for x := range client.Messages {
|
|
|
- writeFormatted(w, render_opts.Format, x)
|
|
|
- if render_opts.Format != formatJSON { // bleah
|
|
|
- w.Write([]byte("\n"))
|
|
|
+ if err := render_opts.Format.WriteFormatted(w, x); err == nil {
|
|
|
+ if render_opts.Format != formatter.FormatJSON { // bleah
|
|
|
+ w.Write([]byte("\n"))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -166,7 +167,7 @@ func getWSHandler(hub circolog.Hub) http.HandlerFunc {
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- writeFormatted(w, render_opts.Format, message)
|
|
|
+ render_opts.Format.WriteFormatted(w, message)
|
|
|
|
|
|
if err := w.Close(); err != nil {
|
|
|
return
|