Documentation ¶
Index ¶
- func GetParams(r *http.Request) httprouter.Params
- type HandlerUnwrapper
- type Server
- func (s *Server) AddDynamicLocalDir(prefix string, getPath func(*http.Request) http.FileSystem) *Server
- func (s *Server) AddFile(path, file string) *Server
- func (s *Server) AddStaticLocalDir(prefix, path string) *Server
- func (s *Server) Delete(path string, handler http.Handler, middlewares ...middleware.Middleware)
- func (s *Server) DeleteF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
- func (s *Server) EnableAutocert(caDirEndpoint, cacheDir string, hostPolicy autocert.HostPolicy) error
- func (s *Server) EnableLetsEncrypt(cacheDir string, hostPolicy autocert.HostPolicy) error
- func (s *Server) Get(path string, handler http.Handler, middlewares ...middleware.Middleware)
- func (s *Server) GetF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
- func (s *Server) GetServices() []Service
- func (s *Server) Handle(method, path string, handler http.Handler, ...)
- func (s *Server) Handler() http.Handler
- func (s *Server) Head(path string, handler http.Handler, middlewares ...middleware.Middleware)
- func (s *Server) HeadF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
- func (s *Server) IsMaster() bool
- func (s *Server) Options(path string, handler http.Handler, middlewares ...middleware.Middleware)
- func (s *Server) OptionsF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
- func (s *Server) Patch(path string, handler http.Handler, middlewares ...middleware.Middleware)
- func (s *Server) PatchF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
- func (s *Server) Post(path string, handler http.Handler, middlewares ...middleware.Middleware)
- func (s *Server) PostF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
- func (s *Server) Put(path string, handler http.Handler, middlewares ...middleware.Middleware)
- func (s *Server) PutF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
- func (s *Server) RegisterService(svc Service)
- func (s *Server) SetMaster()
- func (s *Server) StartHTTP(addr string) error
- func (s *Server) StartHTTPS(addr, certFile, keyFile string) error
- func (s *Server) Use(m middleware.Middleware)
- func (s *Server) UseF(m func(http.Handler) http.Handler)
- func (s *Server) UseHandler(h http.Handler)
- func (s *Server) UseTop(m middleware.Middleware)
- func (s *Server) UseTopF(m func(http.Handler) http.Handler)
- type Service
- type ServiceName
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HandlerUnwrapper ¶
type Server ¶
type Server struct { Router *httprouter.Router Logger log.Logger TLSConfig *tls.Config HTTPServer *http.Server // contains filtered or unexported fields }
Server is the main server struct.
func (*Server) AddDynamicLocalDir ¶
func (*Server) AddStaticLocalDir ¶
AddStaticLocalDir adds a local directory to the router.
func (*Server) Delete ¶
func (s *Server) Delete(path string, handler http.Handler, middlewares ...middleware.Middleware)
Delete adds a DELETE handler to the router.
func (*Server) DeleteF ¶
func (s *Server) DeleteF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
DeleteF adds a DELETE HandlerFunc to the router.
func (*Server) EnableAutocert ¶
func (s *Server) EnableAutocert(caDirEndpoint, cacheDir string, hostPolicy autocert.HostPolicy) error
EnableAutocert adds autocert to the server.
caDirEndpoint points to a ca directory endpoint. cacheDir defaults to "private/autocert-cache" when empty. If you use the recommended app layout, leave it empty. hostWhitelist is a list of hosts where the SSL certificate is valid. Supply at least one domain, else it won't work.
func (*Server) EnableLetsEncrypt ¶
func (s *Server) EnableLetsEncrypt(cacheDir string, hostPolicy autocert.HostPolicy) error
EnableLetsEncrypt adds autocert to the server with LetsEncrypt CA dir.
See the documentation of EnableAutocert for cacheDir and hostPolicy.
func (*Server) Get ¶
func (s *Server) Get(path string, handler http.Handler, middlewares ...middleware.Middleware)
Get adds a GET handler to the router.
func (*Server) GetF ¶
func (s *Server) GetF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
GetF adds a GET HandlerFunc to the router.
func (*Server) GetServices ¶
func (*Server) Handle ¶
func (s *Server) Handle(method, path string, handler http.Handler, middlewares ...middleware.Middleware)
Handle adds a handler to the router.
The middleware list will be applied to this handler only.
func (*Server) Handler ¶
Handler creates a http.Handler from the server (using the middlewares and the router).
func (*Server) Head ¶
func (s *Server) Head(path string, handler http.Handler, middlewares ...middleware.Middleware)
Head adds a HEAD handler to the router.
func (*Server) HeadF ¶
func (s *Server) HeadF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
HeadF adds a HEAD HandlerFunc to the router.
func (*Server) Options ¶
func (s *Server) Options(path string, handler http.Handler, middlewares ...middleware.Middleware)
Options adds an OPTIONS handler to the router.
func (*Server) OptionsF ¶
func (s *Server) OptionsF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
OptionsF adds an OPTIONS HandlerFunc to the router.
func (*Server) Patch ¶
func (s *Server) Patch(path string, handler http.Handler, middlewares ...middleware.Middleware)
Patch adds a PATCH handler to the router.
func (*Server) PatchF ¶
func (s *Server) PatchF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
PatchF adds a PATCH HandlerFunc to the router.
func (*Server) Post ¶
func (s *Server) Post(path string, handler http.Handler, middlewares ...middleware.Middleware)
Post adds a POST handler to the router.
func (*Server) PostF ¶
func (s *Server) PostF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
PostF adds a POST HandlerFunc to the router.
func (*Server) Put ¶
func (s *Server) Put(path string, handler http.Handler, middlewares ...middleware.Middleware)
Put adds a PUT handler to the router.
func (*Server) PutF ¶
func (s *Server) PutF(path string, handler http.HandlerFunc, middlewares ...middleware.Middleware)
PutF adds a PUT HandlerFunc to the router.
func (*Server) RegisterService ¶
RegisterService adds a service on the server.
See the Service interface for more information.
func (*Server) SetMaster ¶
func (s *Server) SetMaster()
SetMaster enables master mode on this server.
If a server is in master mode, it will execute SQL updates, and other potentially destructive operations. If you run a cluster, it is important that you either only run one master, or you deploy one master first, and the rest when all changes are finished.
func (*Server) StartHTTPS ¶
StartHTTPS starts the server.
func (*Server) Use ¶
func (s *Server) Use(m middleware.Middleware)
Use adds middlewares to the top of the middleware stack.
func (*Server) UseHandler ¶
UseHandler uses a http.Handler as a middleware.
func (*Server) UseTop ¶
func (s *Server) UseTop(m middleware.Middleware)
UseTop adds middlewares to the bottom of the middleware stack.
type Service ¶
type Service interface { // Name returns the name of this service instance. Name() string // Register the Service endpoints Register(*Server) error }
Service is a collection of endpoints that logically belong together or operate on the same part of the database schema.
type ServiceName ¶
type ServiceName string
func (ServiceName) Name ¶
func (n ServiceName) Name() string