Documentation ¶
Index ¶
- Variables
- func GetHTTPClient(ctx context.Context) *http.Client
- func NewRequest(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)
- func Register(name string, newFunc NewService)
- func RegisterMiddleware(name string, n NewMiddleware)
- func ShiftPath(p string) (head, tail string)
- type Middleware
- type NewMiddleware
- type NewService
- type Server
- type Service
Constants ¶
This section is empty.
Variables ¶
var NewMiddlewares = map[string]NewMiddleware{}
NewMiddlewares contains all the registered new middleware functions.
var Services = map[string]NewService{}
Services is a map of service name and its new function.
Functions ¶
func GetHTTPClient ¶
GetHTTPClient returns an http client with open census tracing support. TODO(labkode): harden it. https://medium.com/@nate510/don-t-use-go-s-default-http-client-4804cb19f779
func NewRequest ¶
NewRequest creates an HTTP request that sets the token if it is passed in ctx.
func Register ¶
func Register(name string, newFunc NewService)
Register registers a new HTTP services with name and new function.
func RegisterMiddleware ¶
func RegisterMiddleware(name string, n NewMiddleware)
RegisterMiddleware registers a new HTTP middleware and its new function.
func ShiftPath ¶
ShiftPath splits off the first component of p, which will be cleaned of relative components before processing. head will never contain a slash and tail will always be a rooted path without trailing slash. see https://blog.merovius.de/2017/06/18/how-not-to-use-an-http-router.html and https://gist.github.com/weatherglass/62bd8a704d4dfdc608fe5c5cb5a6980c#gistcomment-2161690 for the zero alloc code below
Types ¶
type Middleware ¶
Middleware is a middleware http handler.
type NewMiddleware ¶
type NewMiddleware func(conf map[string]interface{}) (Middleware, int, error)
NewMiddleware is the function that HTTP middlewares need to register at init time.
type NewService ¶
NewService is the function that HTTP services need to register at init time.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server contains the server info.
func (*Server) GracefulStop ¶
GracefulStop gracefully stops the server.