cmd/routed: more hacks
This commit is contained in:
parent
28c3094e40
commit
7d6f217f0b
|
@ -148,14 +148,20 @@ func New(cfg Config) (*Server, error) {
|
|||
go s.listenKCP(context.Background(), cfg.BackendKCPAddr, tc)
|
||||
go s.listenTCP(context.Background(), cfg.BackendTCPAddr, tc)
|
||||
|
||||
withHandler := func(disc string, h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
h.ServeHTTP(w, r.WithContext(ln.WithF(r.Context(), ln.F{"disc": disc})))
|
||||
})
|
||||
}
|
||||
|
||||
bhdr := proto.NewBackendsServer(&Backend{Server: s}, s.makeTwirpHooks())
|
||||
rhdr := proto.NewRoutesServer(&Route{Server: s}, s.makeTwirpHooks())
|
||||
thdr := proto.NewTokensServer(&Token{Server: s}, s.makeTwirpHooks())
|
||||
mux := http.NewServeMux()
|
||||
|
||||
mux.Handle(proto.BackendsPathPrefix, bhdr)
|
||||
mux.Handle(proto.RoutesPathPrefix, rhdr)
|
||||
mux.Handle(proto.TokensPathPrefix, thdr)
|
||||
mux.Handle(proto.BackendsPathPrefix, withHandler("backends", bhdr))
|
||||
mux.Handle(proto.RoutesPathPrefix, withHandler("routes", rhdr))
|
||||
mux.Handle(proto.TokensPathPrefix, withHandler("tokens", thdr))
|
||||
|
||||
hs := &http.Server{
|
||||
TLSConfig: tc,
|
||||
|
|
Loading…
Reference in New Issue