You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
crate/cmd/http-reflect-server/main.go

27 lines
671 B
Go

package main
import (
"context"
"flag"
"net/http"
"git.blauwelle.com/go/crate/exegroup"
"git.blauwelle.com/go/crate/log"
"git.blauwelle.com/go/crate/log/logsdk"
"git.blauwelle.com/go/crate/log/logsdk/logjson"
)
var port = flag.Int("port", 8080, "HTTP Port")
func main() {
flag.Parse()
log.Logger().AddProcessor(logsdk.AllLevels, logjson.New())
g := exegroup.Default()
mux := http.NewServeMux()
var handler http.Handler = mux
mux.HandleFunc("/", newHandler())
g.New().WithGoStop(exegroup.HttpListenAndServe(*port, handler))
log.Infof(context.Background(), "listening %d", *port)
log.Error(context.Background(), "exit: ", g.Run(context.Background()))
}