Documentation ¶
Index ¶
- type AnyContext
- type AnyHandler
- type ChainExecutor
- type Context
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (c *Context) FormParam(key string, defs ...string) string
- func (c *Context) FormParamInt64(key string, defs ...int64) int64
- func (c *Context) IsMethodGet() bool
- func (c *Context) IsMethodPost() bool
- func (c *Context) IsResponseWritten() bool
- func (c *Context) PathParam(key string, defs ...string) string
- func (c *Context) PathParamInt64(key string, defs ...int64) int64
- func (c *Context) PostParam(key string, defs ...string) string
- func (c *Context) PostParamInt64(key string, defs ...int64) int64
- func (c *Context) QueryParam(key string, defs ...string) string
- func (c *Context) QueryParamInt64(key string, defs ...int64) int64
- func (c *Context) RealRemoteIp() string
- func (c *Context) RequestJson() *fmutil.JsonValue
- func (c *Context) RequestJsonUnmarshal(v any) error
- func (c *Context) Respond(vars ...any) *ResponseCommon
- func (c *Context) RespondFile(name string, file fs.File) *ResponseCommon
- func (c *Context) RespondJson(v any) *ResponseCommon
- func (c *Context) RespondPathTmpl(data map[string]any) *ResponseCommon
- func (c *Context) RespondRedirectSameSite(location string, params ...fmutil.Map) *ResponseCommon
- func (c *Context) RespondTmpl(name string, data map[string]any) *ResponseCommon
- func (c *Context) Session() *Session
- func (c *Context) UriHost() string
- func (c *Context) Value(key any) any
- type HandlerCaller
- type HttpServer
- func (hs *HttpServer) HandleAssets(pattern string)
- func (hs *HttpServer) HandleRequest(pattern string, handlers ...AnyHandler)
- func (hs *HttpServer) ListenAndServe() error
- func (hs *HttpServer) ServeAssetFile(c *Context) Response
- func (hs *HttpServer) TmplRender(w io.Writer, name string, data map[string]any) error
- func (hs *HttpServer) UseMiddleware(handlers ...AnyHandler)
- type Options
- type PatternDelegator
- func (pd *PatternDelegator) Delete(h ...AnyHandler) *PatternDelegator
- func (pd *PatternDelegator) Get(h ...AnyHandler) *PatternDelegator
- func (pd *PatternDelegator) Head(h ...AnyHandler) *PatternDelegator
- func (pd *PatternDelegator) Options(h ...AnyHandler) *PatternDelegator
- func (pd *PatternDelegator) Patch(h ...AnyHandler) *PatternDelegator
- func (pd *PatternDelegator) Post(h ...AnyHandler) *PatternDelegator
- func (pd *PatternDelegator) Put(h ...AnyHandler) *PatternDelegator
- type RedirectPermanent
- type RedirectSeeOther
- type RedirectTemporary
- type RequestHandler
- type RequestHandlerFunc
- type Response
- type ResponseCommon
- type ResponseWriterWrapper
- type Router
- type Session
- func (ws *Session) AutoSave(w http.ResponseWriter, r *http.Request) error
- func (ws *Session) Destroy()
- func (ws *Session) Get(key string) any
- func (ws *Session) GetInt64(key string) int64
- func (ws *Session) GetString(key string) string
- func (ws *Session) Remove(key string)
- func (ws *Session) Set(key string, val any)
- func (ws *Session) SetChanged()
- type TemplateRender
- type WithDelegator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyContext ¶
type AnyContext any
type AnyHandler ¶
type AnyHandler any
type ChainExecutor ¶
type ChainExecutor struct {
// contains filtered or unexported fields
}
func (*ChainExecutor) Next ¶
func (ce *ChainExecutor) Next() Response
type Context ¶
type Context struct { Request *http.Request WrappedContext AnyContext HttpServer *HttpServer ResponseWriter *ResponseWriterWrapper HandlerData map[string]any // contains filtered or unexported fields }
func (*Context) IsMethodGet ¶
func (*Context) IsMethodPost ¶
func (*Context) IsResponseWritten ¶
func (*Context) QueryParamInt64 ¶
func (*Context) RealRemoteIp ¶
func (*Context) RequestJson ¶
func (*Context) RequestJsonUnmarshal ¶
func (*Context) Respond ¶
func (c *Context) Respond(vars ...any) *ResponseCommon
func (*Context) RespondFile ¶
func (c *Context) RespondFile(name string, file fs.File) *ResponseCommon
func (*Context) RespondJson ¶
func (c *Context) RespondJson(v any) *ResponseCommon
func (*Context) RespondPathTmpl ¶
func (c *Context) RespondPathTmpl(data map[string]any) *ResponseCommon
func (*Context) RespondRedirectSameSite ¶
func (c *Context) RespondRedirectSameSite(location string, params ...fmutil.Map) *ResponseCommon
func (*Context) RespondTmpl ¶
func (c *Context) RespondTmpl(name string, data map[string]any) *ResponseCommon
type HandlerCaller ¶
type HandlerCaller struct {
// contains filtered or unexported fields
}
func NewHandlerCaller ¶
func NewHandlerCaller(p AnyHandler) *HandlerCaller
func (*HandlerCaller) Call ¶
func (hc *HandlerCaller) Call(ce *ChainExecutor, isMiddleware bool) Response
type HttpServer ¶
type HttpServer struct { AssetsDir fs.FS AssetsWebRoot fs.FS WrapContext func(r *Context) AnyContext // contains filtered or unexported fields }
func NewHttpServer ¶
func NewHttpServer(opt *Options) *HttpServer
func (*HttpServer) HandleAssets ¶
func (hs *HttpServer) HandleAssets(pattern string)
func (*HttpServer) HandleRequest ¶
func (hs *HttpServer) HandleRequest(pattern string, handlers ...AnyHandler)
func (*HttpServer) ListenAndServe ¶
func (hs *HttpServer) ListenAndServe() error
func (*HttpServer) ServeAssetFile ¶
func (hs *HttpServer) ServeAssetFile(c *Context) Response
func (*HttpServer) TmplRender ¶
func (*HttpServer) UseMiddleware ¶
func (hs *HttpServer) UseMiddleware(handlers ...AnyHandler)
type PatternDelegator ¶
type PatternDelegator struct {
// contains filtered or unexported fields
}
func (*PatternDelegator) Delete ¶
func (pd *PatternDelegator) Delete(h ...AnyHandler) *PatternDelegator
func (*PatternDelegator) Get ¶
func (pd *PatternDelegator) Get(h ...AnyHandler) *PatternDelegator
func (*PatternDelegator) Head ¶
func (pd *PatternDelegator) Head(h ...AnyHandler) *PatternDelegator
func (*PatternDelegator) Options ¶
func (pd *PatternDelegator) Options(h ...AnyHandler) *PatternDelegator
func (*PatternDelegator) Patch ¶
func (pd *PatternDelegator) Patch(h ...AnyHandler) *PatternDelegator
func (*PatternDelegator) Post ¶
func (pd *PatternDelegator) Post(h ...AnyHandler) *PatternDelegator
func (*PatternDelegator) Put ¶
func (pd *PatternDelegator) Put(h ...AnyHandler) *PatternDelegator
type RedirectPermanent ¶
type RedirectPermanent string
type RedirectSeeOther ¶
type RedirectSeeOther string
type RedirectTemporary ¶
type RedirectTemporary string
type RequestHandler ¶
type RequestHandlerFunc ¶
type ResponseCommon ¶
type ResponseCommon struct {
// contains filtered or unexported fields
}
func (*ResponseCommon) Header ¶
func (wr *ResponseCommon) Header() http.Header
func (*ResponseCommon) RespondTo ¶
func (wr *ResponseCommon) RespondTo(w http.ResponseWriter) (int64, error)
func (*ResponseCommon) SetStatusCode ¶
func (wr *ResponseCommon) SetStatusCode(v int) *ResponseCommon
func (*ResponseCommon) StatusCode ¶
func (wr *ResponseCommon) StatusCode() int
type ResponseWriterWrapper ¶
type ResponseWriterWrapper struct {
// contains filtered or unexported fields
}
func (*ResponseWriterWrapper) Header ¶
func (w *ResponseWriterWrapper) Header() http.Header
func (*ResponseWriterWrapper) Write ¶
func (w *ResponseWriterWrapper) Write(bytes []byte) (int, error)
func (*ResponseWriterWrapper) WriteHeader ¶
func (w *ResponseWriterWrapper) WriteHeader(statusCode int)
type Router ¶
type Router interface { RequestHandler // Use appends one or more middlewares onto the Router stack. Use(middlewares ...AnyHandler) With(h ...AnyHandler) *WithDelegator // Group adds a new inline-Router along the current routing path, with a fresh middleware stack for the inline-Router. Group(fn func(r Router)) Router // Route mounts a sub-Router along a `pattern“ string. Route(pattern string, fn func(r Router)) Router Any(pattern string, h ...AnyHandler) Method(method, pattern string, h ...AnyHandler) Connect(pattern string, h ...AnyHandler) Delete(pattern string, h ...AnyHandler) Get(pattern string, h ...AnyHandler) Head(pattern string, h ...AnyHandler) Options(pattern string, h ...AnyHandler) Patch(pattern string, h ...AnyHandler) Post(pattern string, h ...AnyHandler) Put(pattern string, h ...AnyHandler) Trace(pattern string, h ...AnyHandler) Pattern(pattern string, h ...AnyHandler) *PatternDelegator // NotFound defines a handler to respond whenever a route could not be found. NotFound(h ...AnyHandler) // MethodNotAllowed defines a handler to respond whenever a method is not allowed. MethodNotAllowed(h ...AnyHandler) }
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func (*Session) SetChanged ¶
func (ws *Session) SetChanged()
type TemplateRender ¶
type TemplateRender struct { DevMode bool TemplateFS fs.FS // contains filtered or unexported fields }
func NewTemplateRender ¶
func NewTemplateRender(templateFS fs.FS) *TemplateRender
type WithDelegator ¶
type WithDelegator struct {
// contains filtered or unexported fields
}
func (WithDelegator) Group ¶
func (w WithDelegator) Group(fn func(r Router)) Router
Click to show internal directories.
Click to hide internal directories.