box-o-sand/logstash/crispy/main.go

33 lines
565 B
Go
Raw Normal View History

package main
import (
"log"
"net/http"
"os"
)
func main() {
server := newCrispyServer()
http.Handle("/", server)
log.Printf("Serving on :9764 with %+v\n", server)
log.Fatal(http.ListenAndServe(":9764", nil))
}
type crispyServer struct {
logstasher *log.Logger
}
func newCrispyServer() *crispyServer {
return &crispyServer{
logstasher: newLogstashLogger(),
}
}
func (me *crispyServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
me.logstasher.Printf("%+v\n", r)
}
func newLogstashLogger() *log.Logger {
return log.New(os.Stderr, "", 0)
}