Documentation ¶
Index ¶
- Constants
- type Config
- type ConfigHandler
- type ConfigRouter
- type Plugin
- type Server
- func (s *Server) Connect(pattern string, handlerFn http.HandlerFunc)
- func (s *Server) Delete(pattern string, handlerFn http.HandlerFunc)
- func (s *Server) Get(pattern string, handlerFn http.HandlerFunc)
- func (s *Server) Group(fn func(r chi.Router))
- func (s *Server) Handle(pattern string, handler http.Handler)
- func (s *Server) HandleFunc(pattern string, handlerFn http.HandlerFunc)
- func (s *Server) Head(pattern string, handlerFn http.HandlerFunc)
- func (s *Server) HttpServer() *http.Server
- func (s *Server) Match(ctx *chi.Context, method string, path string)
- func (s *Server) Method(method string, pattern string, handler http.Handler)
- func (s *Server) MethodFunc(method string, pattern string, handlerFn http.HandlerFunc)
- func (s *Server) Mux() *chi.Mux
- func (s *Server) Options(pattern string, handlerFn http.HandlerFunc)
- func (s *Server) Patch(pattern string, handlerFn http.HandlerFunc)
- func (s *Server) Post(pattern string, handlerFn http.HandlerFunc)
- func (s *Server) Put(pattern string, handlerFn http.HandlerFunc)
- func (s *Server) Route(pattern string, fn func(r chi.Router))
- func (s *Server) Serve(ctx context.Context)
- func (s *Server) Shutdown(ctx context.Context)
- func (s *Server) Trace(pattern string, handlerFn http.HandlerFunc)
- func (s *Server) Use(middlewares ...func(http.Handler) http.Handler)
- func (s *Server) With(middlewares ...func(http.Handler) http.Handler) chi.Router
Constants ¶
const (
PluginsRoot = root + ".plugins"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Middlewares []func(http.Handler) http.Handler Handlers []ConfigHandler Routes []ConfigRouter }
Config represents chi plugin configuration.
type ConfigHandler ¶
ConfigHandler represents chi handler configuration.
type ConfigRouter ¶
type ConfigRouter struct { Method string HandlerFunc http.HandlerFunc Pattern string }
ConfigRouter represents chi router configuration.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents a chi http server.
func NewServerWithConfigPath ¶
NewServer creates a new http server for chi with options from path and plugins.
func NewServerWithOptions ¶
NewServer creates a new http server for chi with options and plugins
func (*Server) Connect ¶
func (s *Server) Connect(pattern string, handlerFn http.HandlerFunc)
Connect adds the route `pattern` that matches a CONNECT http method to execute the `handlerFn` http.HandlerFunc.
func (*Server) Delete ¶
func (s *Server) Delete(pattern string, handlerFn http.HandlerFunc)
Delete adds the route `pattern` that matches a DELETE http method to execute the `handlerFn` http.HandlerFunc.
func (*Server) Get ¶
func (s *Server) Get(pattern string, handlerFn http.HandlerFunc)
Get adds the route `pattern` that matches a GET http method to execute the `handlerFn` http.HandlerFunc.
func (*Server) Group ¶
func (s *Server) Group(fn func(r chi.Router))
Group creates a new inline-Mux with a fresh middleware stack. It's useful for a group of handlers along the same routing path that use an additional set of middlewares. See _examples/.
func (*Server) Handle ¶
Handle adds the route `pattern` that matches any http method to execute the `handler` http.Handler.
func (*Server) HandleFunc ¶
func (s *Server) HandleFunc(pattern string, handlerFn http.HandlerFunc)
HandleFunc adds the route `pattern` that matches any http method to execute the `handlerFn` http.HandlerFunc.
func (*Server) Head ¶
func (s *Server) Head(pattern string, handlerFn http.HandlerFunc)
Head adds the route `pattern` that matches a HEAD http method to execute the `handlerFn` http.HandlerFunc.
func (*Server) HttpServer ¶
HtpServer returns the underlying http server.
func (*Server) Match ¶
Match searches the routing tree for a handler that matches the method/path. It's similar to routing a http request, but without executing the handler thereafter.
Note: the *Context state is updated during execution, so manage the state carefully or make a NewRouteContext().
func (*Server) Method ¶
Method adds the route `pattern` that matches `method` http method to execute the `handler` http.Handler.
func (*Server) MethodFunc ¶
func (s *Server) MethodFunc(method string, pattern string, handlerFn http.HandlerFunc)
MethodFunc adds the route `pattern` that matches `method` http method to execute the `handlerFn` http.HandlerFunc.
func (*Server) Options ¶
func (s *Server) Options(pattern string, handlerFn http.HandlerFunc)
Options adds the route `pattern` that matches a OPTIONS http method to execute the `handlerFn` http.HandlerFunc.
func (*Server) Patch ¶
func (s *Server) Patch(pattern string, handlerFn http.HandlerFunc)
Patch adds the route `pattern` that matches a PATCH http method to execute the `handlerFn` http.HandlerFunc.
func (*Server) Post ¶
func (s *Server) Post(pattern string, handlerFn http.HandlerFunc)
Post adds the route `pattern` that matches a POST http method to execute the `handlerFn` http.HandlerFunc.
func (*Server) Put ¶
func (s *Server) Put(pattern string, handlerFn http.HandlerFunc)
Put adds the route `pattern` that matches a PUT http method to execute the `handlerFn` http.HandlerFunc.
func (*Server) Route ¶
Route creates a new Mux with a fresh middleware stack and mounts it along the `pattern` as a subrouter. Effectively, this is a short-hand call to Mount. See _examples/.
func (*Server) Shutdown ¶
Shutdown gracefully shuts down the server without interrupting any active connections.
func (*Server) Trace ¶
func (s *Server) Trace(pattern string, handlerFn http.HandlerFunc)
Trace adds the route `pattern` that matches a TRACE http method to execute the `handlerFn` http.HandlerFunc.
func (*Server) Use ¶
Use appends a middleware handler to the Mux middleware stack.
The middleware stack for any Mux will execute before searching for a matching route to a specific handler, which provides opportunity to respond early, change the course of the request execution, or set request-scoped values for the next http.Handler.