Documentation ¶
Index ¶
- Constants
- Variables
- func ReverseStringSlice(s []string) []string
- type Config
- type HTTPService
- type Handler
- type HandlerFunc
- type Middleware
- type PerRouteMiddleware
- type StatsSummarizer
- type SubRouter
- func (s *SubRouter) Handler(method, path string, handler http.Handler)
- func (s *SubRouter) Route(method, path string, endpoint HandlerFunc)
- func (s *SubRouter) RouteFiles(path string, root http.FileSystem)
- func (s *SubRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *SubRouter) SubRoute(path string) *SubRouter
- func (s *SubRouter) Use(m ...Middleware)
- func (s *SubRouter) UsePerRoute(m ...PerRouteMiddleware)
Constants ¶
const (
AuthenticatedUserKey key = iota + 1
)
Variables ¶
var ( ErrServiceUnhealthy = errors.New("HTTP service unhealthy") ErrDecode = errors.New("can't decode JSON message") )
Functions ¶
func ReverseStringSlice ¶
Types ¶
type Config ¶
type HTTPService ¶
type HTTPService struct {
// contains filtered or unexported fields
}
func New ¶ added in v0.1.10
func New( config *Config, db letterbox.Datastore, log logger.Logger, info *letterbox.Info, hasher letterbox.ArgonHasher, badActors *badactor.Studio, domains *letterbox.DomainService, mailboxes *letterbox.MailboxService, messages *letterbox.MessageService, users *letterbox.UserService, statsSummary StatsSummarizer, ) *HTTPService
func (*HTTPService) Name ¶
func (s *HTTPService) Name() string
func (*HTTPService) Start ¶
func (s *HTTPService) Start() error
func (*HTTPService) Stop ¶
func (s *HTTPService) Stop() error
type Handler ¶ added in v0.1.10
type Handler struct { Handler HandlerFunc // contains filtered or unexported fields }
Handler wraps a HandlerFunc with a logger to provide consistent logging.
func (Handler) ServeHTTP ¶ added in v0.1.10
func (a Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP will call the wrapped HandlerFunc. If the returned interface{} is non-nil, it is to be the response body. If error is non-nil, an HTTP error message is to be returned. See getStatusCodeForError to determine how specific errors are mapped to HTTP status codes.
type HandlerFunc ¶ added in v0.1.10
type HandlerFunc func(http.ResponseWriter, *http.Request) (interface{}, error)
HandlerFunc describes our custom HTTP handler definition. It's similar to a standard http.HandlerFunc, except it also allows returning an interface{} and an error.
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 StatsSummarizer ¶ added in v0.1.14
type StatsSummarizer interface {
GetStats(mailbox *letterbox.Mailbox) ([]letterbox.DomainStat, error)
}
type SubRouter ¶
type SubRouter struct {
// contains filtered or unexported fields
}
func (*SubRouter) Route ¶
func (s *SubRouter) Route(method, path string, endpoint HandlerFunc)
func (*SubRouter) RouteFiles ¶
func (s *SubRouter) RouteFiles(path string, root http.FileSystem)
func (*SubRouter) ServeHTTP ¶ added in v0.1.10
func (s *SubRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*SubRouter) Use ¶ added in v0.1.10
func (s *SubRouter) Use(m ...Middleware)
func (*SubRouter) UsePerRoute ¶ added in v0.1.10
func (s *SubRouter) UsePerRoute(m ...PerRouteMiddleware)