httpx

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

README

httpx

Golang HTTP router for based on standard http module but with more features

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Echo added in v0.0.3

func Echo(w http.ResponseWriter, r *http.Request) error

func ServeDir added in v0.0.3

func ServeDir(dir string) types.Handler
 	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

func ServeFile added in v0.0.3

func ServeFile(filePath string) types.Handler

func Text

func Text(text string) types.Handler

Types

type ProtectedFS added in v0.0.3

type ProtectedFS struct {
	// contains filtered or unexported fields
}

func (ProtectedFS) Open added in v0.0.3

func (pfs ProtectedFS) Open(name string) (fs.File, error)

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter() *Router

func (*Router) Catch

func (ro *Router) Catch(handler types.Handler) http.HandlerFunc

func (*Router) ErrorFunc added in v0.2.0

func (router *Router) ErrorFunc(f types.ErrorFunc)

func (*Router) Group added in v0.0.3

func (router *Router) Group(middleware ...types.Middleware) *Router

func (*Router) Listen added in v0.0.3

func (router *Router) Listen(addr string) error

func (*Router) ListenTLS added in v0.0.3

func (router *Router) ListenTLS(addr string, tlsConfig *tls.Config) error

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) RouteH added in v0.1.5

func (router *Router) RouteH(pattern string, h http.Handler, middlewares ...types.Middleware) *Router

func (*Router) RouteHF added in v0.1.5

func (router *Router) RouteHF(pattern string, h http.HandlerFunc, middlewares ...types.Middleware) *Router

func (*Router) ServeHTTP

func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Router) Use

func (router *Router) Use(middlewares ...types.Middleware)

Directories

Path Synopsis
cmd
client command
server command
mux module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL