Documentation
¶
Overview ¶
Package app provides a preconfigured HTTP server.
Index ¶
- func NewMuxRouter() *mux.Router
- type AuthorizeService
- type Authorizer
- type CreateAppService
- type CreateOrgService
- type Driver
- type FindAppService
- type FindOrgService
- type FindUserService
- type LoggerService
- type MiddlewareServices
- type Oauth2TokenConverter
- type PingService
- type SeedService
- type Server
- type ServerParams
- type Services
- type UpdateOrgService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMuxRouter ¶ added in v0.34.0
NewMuxRouter initializes a gorilla/mux router and adds the /api subroute to it
Types ¶
type AuthorizeService ¶ added in v0.39.0
type AuthorizeService interface {
Authorize(lgr zerolog.Logger, r *http.Request, sub audit.Audit) error
}
AuthorizeService determines whether an app and a user can perform an action against a resource
type Authorizer ¶ added in v0.34.0
type Authorizer interface {
Authorize(lgr zerolog.Logger, sub user.User, obj string, act string) error
}
Authorizer interface authorizes access to a resource given a user and action
type CreateAppService ¶ added in v0.39.0
type CreateAppService interface {
Create(ctx context.Context, r *service.CreateAppRequest, adt audit.Audit) (service.AppResponse, error)
}
CreateAppService creates an App
type CreateOrgService ¶ added in v0.39.0
type CreateOrgService interface {
Create(ctx context.Context, r *service.CreateOrgRequest, adt audit.Audit) (service.OrgResponse, error)
}
CreateOrgService creates an Org
type Driver ¶ added in v0.34.0
Driver implements the driver.Server interface. The zero value is a valid http.Server.
func NewDriver ¶ added in v0.34.0
func NewDriver() *Driver
NewDriver creates a Driver with an http.Server with default timeouts.
func (*Driver) ListenAndServe ¶ added in v0.34.0
ListenAndServe sets the address and handler on Driver's http.Server, then calls ListenAndServe on it.
type FindAppService ¶ added in v0.39.0
type FindAppService interface {
// FindAppByAPIKey finds an app given its External ID and determines
// if the given API key is a valid key for it
FindAppByAPIKey(ctx context.Context, realm, appExtlID, apiKey string) (app.App, error)
}
FindAppService retrieves an App
type FindOrgService ¶ added in v0.39.0
type FindOrgService interface {
FindAll(ctx context.Context) ([]service.OrgResponse, error)
FindByExternalID(ctx context.Context, extlID string) (service.OrgResponse, error)
}
FindOrgService retrieves Org information from the datastore
type FindUserService ¶ added in v0.39.0
type FindUserService interface {
FindUserByOauth2Token(ctx context.Context, params service.FindUserParams) (user.User, error)
}
FindUserService retrieves a User
type LoggerService ¶ added in v0.34.0
type LoggerService interface {
Read() service.LoggerResponse
Update(r *service.LoggerRequest) (service.LoggerResponse, error)
}
LoggerService reads and updates the logger state
type MiddlewareServices ¶ added in v0.39.0
type MiddlewareServices struct {
FindAppService FindAppService
FindUserService FindUserService
AuthorizeService AuthorizeService
}
MiddlewareServices are used by middleware handlers
type Oauth2TokenConverter ¶ added in v0.39.0
type Oauth2TokenConverter interface {
Convert(ctx context.Context, token oauth2.Token) (user.User, error)
}
Oauth2TokenConverter interface converts an Oauth2 token to a User
type PingService ¶ added in v0.34.0
type PingService interface {
Ping(ctx context.Context, logger zerolog.Logger) service.PingResponse
}
PingService pings the database and responds whether it is up or down
type SeedService ¶ added in v0.39.0
type SeedService interface {
Seed(ctx context.Context, r *service.SeedRequest) (service.SeedResponse, error)
}
SeedService initializes the database with dependent data
type Server ¶ added in v0.34.0
type Server struct {
Driver driver.Server
// all logging is done with a zerolog.Logger
Logger zerolog.Logger
// Addr optionally specifies the TCP address for the server to listen on,
// in the form "host:port". If empty, ":http" (port 80) is used.
// The service names are defined in RFC 6335 and assigned by IANA.
// See net.Dial for details of the address format.
Addr string
// Services used by middleware handlers
MiddlewareServices
// Services used by the various HTTP routes.
Services
// contains filtered or unexported fields
}
Server represents an HTTP server.
func New ¶ added in v0.39.0
func New(rtr *mux.Router, params *ServerParams) *Server
New initializes a new Server and registers routes to the given router
func (*Server) ListenAndServe ¶ added in v0.34.0
ListenAndServe is a wrapper to use wherever http.ListenAndServe is used.
type ServerParams ¶ added in v0.34.0
type ServerParams struct {
// Logger is used for app logging
Logger zerolog.Logger
// Driver serves HTTP requests.
Driver driver.Server
}
ServerParams is the set of configuration parameters for a Server
type Services ¶ added in v0.39.0
type Services struct {
//CreateMovieService CreateMovieService
//UpdateMovieService UpdateMovieService
//DeleteMovieService DeleteMovieService
//FindMovieService FindMovieService
SeedService SeedService
PingService PingService
LoggerService LoggerService
CreateOrgService CreateOrgService
UpdateOrgService UpdateOrgService
FindOrgService FindOrgService
CreateAppService CreateAppService
}
Services are used by the application service handlers
type UpdateOrgService ¶ added in v0.39.0
type UpdateOrgService interface {
Update(ctx context.Context, r *service.UpdateOrgRequest, adt audit.Audit) (service.OrgResponse, error)
}
UpdateOrgService updates an Org