Documentation
¶
Overview ¶
Package server provides a preconfigured HTTP server.
Index ¶
- func NewMuxRouter() *mux.Router
- type AppService
- type CreateMovieService
- type DeleteMovieService
- type Driver
- type FindMovieService
- type GenesisService
- type LoggerService
- type MiddlewareService
- type OrgService
- type PermissionService
- type PingService
- type RegisterUserService
- type RoleService
- type Server
- type Services
- type UpdateMovieService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMuxRouter ¶ added in v0.39.3
NewMuxRouter initializes a gorilla/mux router and adds the /api subroute to it
Types ¶
type AppService ¶ added in v0.41.0
type AppService interface {
Create(ctx context.Context, r *service.CreateAppRequest, adt audit.Audit) (service.AppResponse, error)
Update(ctx context.Context, r *service.UpdateAppRequest, adt audit.Audit) (service.AppResponse, error)
}
AppService manages the retrieval and manipulation of an App
type CreateMovieService ¶ added in v0.40.0
type CreateMovieService interface {
Create(ctx context.Context, r *service.CreateMovieRequest, adt audit.Audit) (service.MovieResponse, error)
}
CreateMovieService creates a Movie
type DeleteMovieService ¶ added in v0.40.0
type DeleteMovieService interface {
Delete(ctx context.Context, extlID string) (service.DeleteResponse, error)
}
DeleteMovieService is a service for deleting a Movie
type Driver ¶ added in v0.39.3
Driver implements the driver.Server interface. The zero value is a valid http.Server.
func NewDriver ¶ added in v0.39.3
func NewDriver() *Driver
NewDriver creates a Driver with an http.Server with default timeouts.
func (*Driver) ListenAndServe ¶ added in v0.39.3
ListenAndServe sets the address and handler on Driver's http.Server, then calls ListenAndServe on it.
type FindMovieService ¶ added in v0.40.0
type FindMovieService interface {
FindMovieByID(ctx context.Context, extlID string) (service.MovieResponse, error)
FindAllMovies(ctx context.Context) ([]service.MovieResponse, error)
}
FindMovieService interface reads a Movie form the database
type GenesisService ¶ added in v0.40.0
type GenesisService interface {
// Seed initializes required dependent data in database
Seed(ctx context.Context, r *service.GenesisRequest) (service.FullGenesisResponse, error)
// ReadConfig reads the local config file generated as part of Seed (when run locally).
// Is only a utility to help with local testing.
ReadConfig() (service.FullGenesisResponse, error)
}
GenesisService initializes the database with dependent data
type LoggerService ¶ added in v0.39.3
type LoggerService interface {
Read() service.LoggerResponse
Update(r *service.LoggerRequest) (service.LoggerResponse, error)
}
LoggerService reads and updates the logger state
type MiddlewareService ¶ added in v0.41.0
type MiddlewareService 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)
// FindUserByOauth2Token retrieves a User given an Oauth2 token
FindUserByOauth2Token(ctx context.Context, params service.FindUserParams) (user.User, error)
// Authorize determines whether an app/user (as part of an Audit
// struct) can perform an action against a resource
Authorize(lgr zerolog.Logger, r *http.Request, sub audit.Audit) error
}
MiddlewareService are all the services uses by the various middleware functions
type OrgService ¶ added in v0.41.0
type OrgService interface {
Create(ctx context.Context, r *service.CreateOrgRequest, adt audit.Audit) (service.OrgResponse, error)
Update(ctx context.Context, r *service.UpdateOrgRequest, adt audit.Audit) (service.OrgResponse, error)
Delete(ctx context.Context, extlID string) (service.DeleteResponse, error)
FindAll(ctx context.Context) ([]service.OrgResponse, error)
FindByExternalID(ctx context.Context, extlID string) (service.OrgResponse, error)
}
OrgService manages the retrieval and manipulation of an Org
type PermissionService ¶ added in v0.43.0
type PermissionService interface {
Create(ctx context.Context, r *auth.Permission, adt audit.Audit) (auth.Permission, error)
FindAll(ctx context.Context) ([]auth.Permission, error)
}
PermissionService allows for creating, updating, reading and deleting a Permission
type PingService ¶ added in v0.39.3
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 RegisterUserService ¶ added in v0.40.0
RegisterUserService registers a new user
type RoleService ¶ added in v0.43.0
type RoleService interface {
Create(ctx context.Context, r *auth.Role, adt audit.Audit) (auth.Role, error)
}
RoleService allows for creating, updating, reading and deleting a Role as well as assigning permissions and users to it.
type Server ¶
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 the various HTTP routes and middleware.
Services
// contains filtered or unexported fields
}
Server represents an HTTP server.
func (*Server) ListenAndServe ¶ added in v0.39.3
ListenAndServe is a wrapper to use wherever http.ListenAndServe is used.
type Services ¶ added in v0.39.3
type Services struct {
CreateMovieService CreateMovieService
UpdateMovieService UpdateMovieService
DeleteMovieService DeleteMovieService
FindMovieService FindMovieService
OrgService OrgService
AppService AppService
RegisterUserService RegisterUserService
PingService PingService
LoggerService LoggerService
GenesisService GenesisService
MiddlewareService MiddlewareService
PermissionService PermissionService
RoleService RoleService
}
Services are used by the application service handlers
type UpdateMovieService ¶ added in v0.40.0
type UpdateMovieService interface {
Update(ctx context.Context, r *service.UpdateMovieRequest, adt audit.Audit) (service.MovieResponse, error)
}
UpdateMovieService is a service for updating a Movie