Documentation
¶
Index ¶
- func DefaultErrTemplate() *template.Template
- func IsWebSocketRequest(r *http.Request) bool
- func NewHandler(handler func(ctx *Context), opts ...Option) http.HandlerFunc
- func NewWrapper(handler http.Handler, opts ...Option) http.HandlerFunc
- func NewWrapperFunc(handler http.HandlerFunc, opts ...Option) http.HandlerFunc
- type CapturedError
- type Context
- func (ctx *Context) AddInteralMessage(a ...any)
- func (ctx *Context) Body() ([]byte, error)
- func (ctx *Context) BodyString() (string, error)
- func (ctx *Context) DeleteCookie(name string)
- func (ctx *Context) DisableErrorCapture()
- func (ctx *Context) DisableLogging()
- func (ctx *Context) Error(statusCode int, message string, a ...any)
- func (ctx *Context) GetCookie(name string, value any) error
- func (ctx *Context) GetCookiePerm(name string, value any) error
- func (ctx *Context) Header() http.Header
- func (ctx *Context) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (ctx *Context) IsSecure() bool
- func (ctx *Context) IsWebSocketRequest() bool
- func (ctx *Context) JSON(data []byte)
- func (ctx *Context) Logger() *logger.Logger
- func (ctx *Context) Main() *Context
- func (ctx *Context) Method() string
- func (ctx *Context) MimeType(mime string)
- func (ctx *Context) NewReverseProxy(dest string, prefix string, base string) (http.Handler, *httputil.ReverseProxy, *websocketproxy.WebsocketProxy, error)
- func (ctx *Context) R() *http.Request
- func (ctx *Context) ReadJSON(value any) error
- func (ctx *Context) Redirect(url string, code int)
- func (ctx *Context) RemoteAddr() string
- func (ctx *Context) RequestHeader() http.Header
- func (ctx *Context) RequestPath() string
- func (ctx *Context) ReverseProxy(dest string, prefix string, base string) error
- func (ctx *Context) ServeCached(uri string)
- func (ctx *Context) ServeContent(name string, modtime time.Time, content io.ReadSeeker)
- func (ctx *Context) ServeFile(name string)
- func (ctx *Context) ServeFileFS(dir fs.FS, name string)
- func (ctx *Context) ServePHP(php *PHPProcessor, dir string)
- func (ctx *Context) ServeStatic()
- func (ctx *Context) SetCookie(name string, value any, maxAge int, opts ...middleware.CookieOption) error
- func (ctx *Context) SetCookiePerm(name string, value any, maxAge int, opts ...middleware.CookieOption) error
- func (ctx *Context) SetCustomHostLog(host string)
- func (ctx *Context) SetErrorTemplate(t *template.Template)
- func (ctx *Context) SetLogger(l *logger.Logger)
- func (ctx *Context) SetRemoteAddr(addr string)
- func (ctx *Context) String(s string)
- func (ctx *Context) W() http.ResponseWriter
- func (ctx *Context) Write(data []byte) (int, error)
- func (ctx *Context) WriteHeader(statusCode int)
- type Nix
- type Option
- func CacheOption(cache *middleware.Cache) Option
- func ConnectToMainOption() Option
- func CookieManagerOption(cm *middleware.CookieManager) Option
- func CustomHostLogOption(host string) Option
- func EnableErrorCaptureOption() Option
- func EnableLoggingOption() Option
- func EnableRecoveryOption() Option
- func ErrorTemplateOption(t *template.Template) Option
- func LoggerOption(l *logger.Logger) Option
- func MainOption() Option
- type PHPProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultErrTemplate ¶
func IsWebSocketRequest ¶ added in v0.1.0
func NewHandler ¶
func NewHandler(handler func(ctx *Context), opts ...Option) http.HandlerFunc
func NewWrapper ¶
func NewWrapper(handler http.Handler, opts ...Option) http.HandlerFunc
func NewWrapperFunc ¶
func NewWrapperFunc(handler http.HandlerFunc, opts ...Option) http.HandlerFunc
Types ¶
type CapturedError ¶
type CapturedError struct {
Code int
Data []byte
DataType string
// contains filtered or unexported fields
}
func (CapturedError) Error ¶
func (err CapturedError) Error() string
func (CapturedError) Internal ¶
func (err CapturedError) Internal() string
func (CapturedError) Message ¶
func (err CapturedError) Message() string
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) AddInteralMessage ¶
func (*Context) BodyString ¶
BodyString returns the response body as a string
func (*Context) DeleteCookie ¶
func (*Context) DisableErrorCapture ¶
func (ctx *Context) DisableErrorCapture()
func (*Context) DisableLogging ¶
func (ctx *Context) DisableLogging()
func (*Context) Error ¶
Error is used to manually report an HTTP Error to send to the client.
It sets the http status code (so it should not be set before) and if the connection is done via a GET request, it will try to serve the html Error template with the status code and Error message in it, otherwise if the Error template does not exist or the request is done via another method (like POST), the Error message will be sent as a plain text.
The last optional list of elements can be used just for logging or debugging: the elements will be saved in the logs
func (*Context) IsWebSocketRequest ¶ added in v0.1.0
func (*Context) NewReverseProxy ¶
func (ctx *Context) NewReverseProxy(dest string, prefix string, base string) (http.Handler, *httputil.ReverseProxy, *websocketproxy.WebsocketProxy, error)
func (*Context) RemoteAddr ¶ added in v0.1.2
func (*Context) RequestHeader ¶
func (*Context) RequestPath ¶
func (*Context) ReverseProxy ¶
ReverseProxy runs a reverse proxy to the provided url. Returns an error is the url could not be parsed or if an error has occurred during the connection
func (*Context) ServeCached ¶ added in v0.0.3
func (*Context) ServeContent ¶
func (*Context) ServePHP ¶
func (ctx *Context) ServePHP(php *PHPProcessor, dir string)
func (*Context) ServeStatic ¶
func (ctx *Context) ServeStatic()
func (*Context) SetCookie ¶
func (ctx *Context) SetCookie(name string, value any, maxAge int, opts ...middleware.CookieOption) error
func (*Context) SetCookiePerm ¶
func (ctx *Context) SetCookiePerm(name string, value any, maxAge int, opts ...middleware.CookieOption) error
func (*Context) SetCustomHostLog ¶
func (*Context) SetErrorTemplate ¶
func (*Context) SetRemoteAddr ¶ added in v0.1.2
func (*Context) W ¶
func (ctx *Context) W() http.ResponseWriter
func (*Context) WriteHeader ¶
WriteHeader is the equivalent of the http.ResponseWriter method but handles multiple calls, using only the first one used
type Nix ¶
type Nix struct {
// contains filtered or unexported fields
}
func (*Nix) WrapFunc ¶
func (n *Nix) WrapFunc(handler http.HandlerFunc) http.HandlerFunc
type Option ¶
type Option func(ctx *Context)
func CacheOption ¶
func CacheOption(cache *middleware.Cache) Option
func ConnectToMainOption ¶
func ConnectToMainOption() Option
func CookieManagerOption ¶
func CookieManagerOption(cm *middleware.CookieManager) Option
func CustomHostLogOption ¶
func EnableErrorCaptureOption ¶
func EnableErrorCaptureOption() Option
func EnableLoggingOption ¶
func EnableLoggingOption() Option
func EnableRecoveryOption ¶
func EnableRecoveryOption() Option
func ErrorTemplateOption ¶
func LoggerOption ¶
func MainOption ¶
func MainOption() Option
type PHPProcessor ¶
type PHPProcessor struct {
Process *process.Process
Logger *logger.Logger
// contains filtered or unexported fields
}
func NewPHPProcessor ¶
func NewPHPProcessor(port int, args ...string) (php *PHPProcessor, err error)
func (*PHPProcessor) Start ¶
func (php *PHPProcessor) Start() error
func (*PHPProcessor) Stop ¶
func (php *PHPProcessor) Stop() error