Documentation ¶
Overview ¶
Package ws provides a simple web server.
Index ¶
- Variables
- func RealIP(r *http.Request) (netip.Addr, error)
- type Checker
- type Error
- type Router
- func (a *Router) MaxBodyBytes(n int64)
- func (a *Router) MustProvide(constructor any, itype any)
- func (a *Router) MustRegisterFS(key string, fsys fs.FS)
- func (a *Router) Provide(constructor any, itype any) error
- func (a *Router) Redirect(opath, npath string)
- func (a *Router) Register(key string, rcvr any, methods ...string)
- func (a *Router) RegisterFN(key string, fn any, methods ...string)
- func (a *Router) RegisterFS(key string, fsys fs.FS) error
- func (a *Router) Route(keys ...string) *Router
- type Server
- func (a *Server) Addr(addr string) *Server
- func (a *Server) Config(f func(s *http.Server)) *Server
- func (a *Server) IdleTimeout(d time.Duration) *Server
- func (a *Server) Logger(logger *log.Logger) *Server
- func (a *Server) MaxBodyBytes(n int64) *Server
- func (a *Server) MaxHeaderBytes(n int) *Server
- func (a *Server) ReadHeaderTimeout(d time.Duration) *Server
- func (a *Server) ReadTimeout(d time.Duration) *Server
- func (a *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *Server) Start(ctx context.Context, wg *sync.WaitGroup)
- func (a *Server) TLS(certfile, keyfile string) *Server
- func (a *Server) WriteTimeout(d time.Duration) *Server
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotModified = NewError(http.StatusNotModified) ErrBadRequest = NewError(http.StatusBadRequest) ErrForbidden = NewError(http.StatusForbidden) ErrNotFound = NewError(http.StatusNotFound) ErrMethodNotAllowed = NewError(http.StatusMethodNotAllowed) ErrTooManyRequests = NewError(http.StatusTooManyRequests) )
Errors.
Functions ¶
Types ¶
type Checker ¶ added in v0.1.2
type Checker interface {
Check() error
}
Checker represents a model checker.
type Error ¶ added in v0.1.2
type Error struct {
// contains filtered or unexported fields
}
Error represents a custom error.
func Errorf ¶ added in v0.1.2
Errorf formats according to a format specifier and returns the string as a value that satisfies error.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router represents a router.
func (*Router) MaxBodyBytes ¶ added in v0.1.2
MaxBodyBytes controls the maximum number of bytes the decoder will read the body.
func (*Router) MustProvide ¶ added in v0.1.2
MustProvide is like Provide but panics if has error.
func (*Router) MustRegisterFS ¶ added in v0.1.2
MustRegisterFS registers the fs, and panic if any error.
func (*Router) Provide ¶ added in v0.1.2
Provide teaches the injector how to build values and expresses their dependencies.
func (*Router) RegisterFN ¶ added in v0.1.2
RegisterFN registers the function handler.
func (*Router) RegisterFS ¶ added in v0.1.2
RegisterFS registers the fs.
type Server ¶
type Server struct { Router // contains filtered or unexported fields }
Server represents a web server.
func (*Server) Addr ¶ added in v0.0.3
Addr optionally specifies the TCP address for the server to listen on.
func (*Server) IdleTimeout ¶ added in v0.0.3
IdleTimeout is the maximum amount of time to wait for the next request when keep-alives are enabled.
func (*Server) MaxBodyBytes ¶ added in v0.1.2
MaxBodyBytes controls the maximum number of bytes the decoder will read the body.
func (*Server) MaxHeaderBytes ¶ added in v0.0.3
MaxHeaderBytes controls the maximum number of bytes the server will read parsing the request header's keys and values.
func (*Server) ReadHeaderTimeout ¶ added in v0.0.3
ReadHeaderTimeout is the amount of time allowed to read request headers.
func (*Server) ReadTimeout ¶ added in v0.0.3
ReadTimeout is the maximum duration for reading the entire request, including the body.
func (*Server) ServeHTTP ¶
func (a *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP should write reply headers and data to the ResponseWriter and then return.