You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Leland Batey edited this page Aug 2, 2017
·
3 revisions
Here is a way to wrap an http handler with a custom main.go
Create your own NAME-service/cmd/NAME-custom-server/main.go
Write something like this:
package main
import (
"context"
"flag"
"net/http"
// This Service
"github.com/TuneLab/truss/_example/echo-service/svc"
"github.com/TuneLab/truss/_example/echo-service/svc/server"
"github.com/TuneLab/truss/_example/echo-service/svc/server/cli"
)
func main() {
// Update addresses if they have been overwritten by flags
flag.Parse()
ctx := context.Background()
endpoints := server.NewEndpoints()
h := svc.MakeHTTPHandler(ctx, endpoints)
h = HandlerWrapper(h)
http.ListenAndServe(cli.Config.HTTPAddr, h)
}
func HandlerWrapper(h http.Handler) http.Handler {
return h
}