Documentation
¶
Index ¶
- func Host(ctx context.Context) string
- func Method(ctx context.Context) []string
- func Middleware(ctx context.Context) []server.Middleware
- func New(c Config) (server.Task, error)
- func NewMatchedRoute(route *route, method, host, request string, params ...string) *matchedRoute
- func NewRoute(ctx context.Context, host, prefix string, methods ...string) *route
- func NewRouteWithPath(ctx context.Context, host, prefix, path string, methods ...string) *route
- func NewRouteWithRegexp(ctx context.Context, host, prefix string, path *regexp.Regexp, ...) *route
- func Params(ctx context.Context) []string
- func Prefix(ctx context.Context) string
- func Scope(ctx context.Context) []string
- func Time(ctx context.Context) time.Time
- func WithHost(ctx context.Context, host string) context.Context
- func WithHostPrefix(ctx context.Context, host, prefix string) context.Context
- func WithMethod(ctx context.Context, method ...string) context.Context
- func WithMiddleware(ctx context.Context, middleware ...server.Middleware) context.Context
- func WithPrefix(ctx context.Context, prefix string) context.Context
- func WithRoute(ctx context.Context, route *matchedRoute) context.Context
- func WithScope(ctx context.Context, scope ...string) context.Context
- func WithTime(ctx context.Context, t time.Time) context.Context
- type Config
- type Route
- type Router
- type RouterContextKey
- type ServiceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
Middleware returns a set of middleware from the context, or zero value if not defined
func NewMatchedRoute ¶ added in v1.4.7
func NewRouteWithPath ¶ added in v1.4.7
func NewRouteWithRegexp ¶ added in v1.4.7
func WithHostPrefix ¶
WithHostPrefix returns a context with the given host and prefix
func WithMethod ¶ added in v1.4.7
WithMethod returns a context with the given methods
func WithMiddleware ¶
WithMiddleware returns a context with the given middleware
func WithPrefix ¶
WithPrefix returns a context with the given prefix
Types ¶
type Config ¶
type Config struct {
Services ServiceConfig `hcl:"services"`
}
func (Config) Description ¶
Description returns the description of the service
type Router ¶
type Router interface { server.Router // Match a host, method and path to a handler. Returns the appropriate // http status code, which will be 200 on success, 404 or 405 and // path parameters extracted from the path. Match(host, method, path string) (*matchedRoute, int) // Add a service endpoint to the router, with specified host/prefix combinarion. AddServiceEndpoints(string, server.ServiceEndpoints, ...server.Middleware) // Return all known scopes Scopes() []string }
type RouterContextKey ¶
type RouterContextKey int
type ServiceConfig ¶
type ServiceConfig map[string]struct { Service server.ServiceEndpoints `hcl:"service"` Middleware []server.Middleware `hcl:"middleware"` }
Click to show internal directories.
Click to hide internal directories.