Documentation
¶
Index ¶
- func Echo(w http.ResponseWriter, r *http.Request) error
- func ServeDir(dir string) types.Handler
- func ServeFile(filePath string) types.Handler
- func Text(text string) types.Handler
- type ProtectedFS
- type Router
- func (ro *Router) Catch(handler types.Handler) http.HandlerFunc
- func (router *Router) ErrorFunc(f types.ErrorFunc)
- func (router *Router) Group(middleware ...types.Middleware) *Router
- func (router *Router) Listen(addr string) error
- func (router *Router) ListenTLS(addr string, tlsConfig *tls.Config) error
- func (router *Router) LoggerFunc(f types.LoggerFunc)
- func (router *Router) Route(pattern string, h types.Handler, middlewares ...types.Middleware) *Router
- func (router *Router) RouteH(pattern string, h http.Handler, middlewares ...types.Middleware) *Router
- func (router *Router) RouteHF(pattern string, h http.HandlerFunc, middlewares ...types.Middleware) *Router
- func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (router *Router) Use(middlewares ...types.Middleware)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServeDir ¶ added in v0.0.3
ServeDir servers dir files dynamically based on request URL path:
file_to_serve = dir_path + url_path
file_to_serve = dir_path + StripPrefix(url_path, prefix)
Route("/", httpx.ServeDir("/data/static"))
GET /1.html --> 200 OK /data/static/1.html
GET /2.html --> 200 OK /data/static/2.html
Route("/data/static", httpx.ServeDir("/data/static"))
GET /data/static/1.html --> 404 Not Found /data/static/data/static/1.html
GET /data/static/2.html --> 404 Not Found /data/static/data/static/2.html
r.Route("/static", httpx.ServeDir("/data/static"), middleware.StripPrefix("/static"))
GET /static/1.html --> 200 OK /data/static/1.html
GET /static/2.html --> 200 OK /data/static/2.html
Types ¶
type ProtectedFS ¶ added in v0.0.3
type ProtectedFS struct {
// contains filtered or unexported fields
}
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Group ¶ added in v0.0.3
func (router *Router) Group(middleware ...types.Middleware) *Router
func (*Router) LoggerFunc ¶ added in v0.0.3
func (router *Router) LoggerFunc(f types.LoggerFunc)
func (*Router) Route ¶ added in v0.0.3
func (router *Router) Route(pattern string, h types.Handler, middlewares ...types.Middleware) *Router
Patterns can match the method, host and path of a request. Some examples:
"/index.html" matches the path "/index.html" for any host and method.
"GET /static/" matches a GET request whose path begins with "/static/".
"example.com/" matches any request to the host "example.com".
"example.com/{$}" matches requests with host "example.com" and path "/".
"/b/{bucket}/o/{objectname...}" matches paths whose first segment is "b" and whose third segment is "o".
func (*Router) RouteHF ¶ added in v0.1.5
func (router *Router) RouteHF(pattern string, h http.HandlerFunc, middlewares ...types.Middleware) *Router
func (*Router) Use ¶
func (router *Router) Use(middlewares ...types.Middleware)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.