Documentation
¶
Index ¶
- Constants
- Variables
- func AddValueToContext(r *http.Request, key key, value interface{}) *http.Request
- func GetAuthenticatedUser(r *http.Request) (*letterbox.User, error)
- func GetMailboxByURLPath(r *http.Request, db letterbox.Datastore) (*letterbox.Mailbox, error)
- func ReverseStringSlice(s []string) []string
- type AppEndpoint
- type AppHandler
- type Config
- type EndpointMetricsMiddleware
- type HTTPService
- type Middleware
- type PerRouteMiddleware
- type SubRouter
Constants ¶
View Source
const (
AuthenticatedUserKey key = iota + 1
)
Variables ¶
View Source
var ( ErrServiceUnhealthy = errors.New("HTTP service unhealthy") ErrDecode = errors.New("can't decode JSON message") )
Functions ¶
func AddValueToContext ¶
func GetMailboxByURLPath ¶
func ReverseStringSlice ¶
Types ¶
type AppEndpoint ¶
type AppEndpoint struct { Handler AppHandler Server *HTTPService }
func (AppEndpoint) ServeHTTP ¶
func (a AppEndpoint) ServeHTTP(w http.ResponseWriter, r *http.Request)
type AppHandler ¶
type AppHandler func(http.ResponseWriter, *http.Request) (interface{}, error)
type Config ¶
type EndpointMetricsMiddleware ¶
type EndpointMetricsMiddleware struct {
MetricsCollector middleware.Middleware
}
func (*EndpointMetricsMiddleware) AddMiddleware ¶
type HTTPService ¶
type HTTPService struct { Config Config PerRouteMiddlewares []PerRouteMiddleware Router *httprouter.Router IsHealthy int32 MaxShutdownTime time.Duration // Service Dependencies DB letterbox.Datastore Logger *logger.Logger ServerInfo *letterbox.Info Hasher letterbox.ArgonHasher // contains filtered or unexported fields }
func (*HTTPService) AddEndpoint ¶
func (s *HTTPService) AddEndpoint(handler AppHandler) *AppEndpoint
func (*HTTPService) Name ¶
func (s *HTTPService) Name() string
func (*HTTPService) Start ¶
func (s *HTTPService) Start() error
func (*HTTPService) Stop ¶
func (s *HTTPService) Stop() error
func (*HTTPService) SubRoute ¶
func (s *HTTPService) SubRoute(path string) *SubRouter
type Middleware ¶
func AuthMiddleware ¶
func AuthMiddleware(s *HTTPService) Middleware
func BadActorMiddleware ¶
func BadActorMiddleware(s *HTTPService) Middleware
type PerRouteMiddleware ¶
PerRouteMiddleware adds middleware that requires information about the specific paths used (e.g. HTTP metric collection, which needs to know what path a given function is registered to).
type SubRouter ¶
type SubRouter struct { // The full path prefix that this SubRouter is adding to Path string // The router to add routes to Server *HTTPService // Middleware to append to all child routes. These get appended to an extra subroutes Middlewares []Middleware }
func (*SubRouter) AddMiddleware ¶
func (s *SubRouter) AddMiddleware(m ...Middleware)
func (*SubRouter) RouteFiles ¶
func (s *SubRouter) RouteFiles(path string, root http.FileSystem)
Click to show internal directories.
Click to hide internal directories.