Documentation ¶
Index ¶
- Constants
- Variables
- func Authenticator(next http.Handler) http.Handler
- func PrintRoute(r Routes)
- func Provide(ctors ...any) fx.Option
- func ResolveHandler(in any) (handler http.Handler)
- func ResolvePattern(in string) (method, pattern string)
- func Run(params Params)
- func Serve(handler http.Handler)
- func ServeHTTP(handler http.Handler)
- func ServeHTTPS(mux http.Handler)
- func SetTemplateFs(fsys fs.FS)
- func Struct(r Router, s any)
- func Supply(values ...Route) fx.Option
- func Validator(next http.Handler) http.Handler
- type Context
- func (c Context) Blob(v []byte, contentType string)
- func (c Context) Claims() M
- func (c Context) ClaimsValue(key string) any
- func (c Context) Cookie(name string) string
- func (c Context) Error(err error)
- func (c Context) File(filename string, attachName string)
- func (c Context) FileBlob(data []byte, contentType string, attachName string)
- func (c Context) FlatMap(keyValue ...any)
- func (c Context) FormFile(fields ...string) (h *multipart.FileHeader)
- func (c Context) FormFiles(fields ...string) (hs []*multipart.FileHeader)
- func (c Context) GetDB() *gorm.DB
- func (c Context) GetJSON(url string) (any, error)
- func (c Context) GetStatus() int
- func (c Context) GetUID() (id int)
- func (c Context) HTML(data string)
- func (c Context) Header() http.Header
- func (c Context) HeaderGet(name string) string
- func (c Context) HeaderSet(name, value string)
- func (c Context) Host() (host string)
- func (c Context) IsTLS() bool
- func (c Context) JSON(v any, pretty ...bool)
- func (c Context) JSONBlob(jsonBytes []byte)
- func (c Context) Jwt() *Jwt
- func (c Context) Msg(errmsg string, errno ...int)
- func (c Context) NoContent()
- func (c Context) NotFound()
- func (c Context) Origin() string
- func (c Context) Path() string
- func (c Context) PathDir() string
- func (c Context) PlainText(data string)
- func (c Context) Port() (port int)
- func (c Context) Query(name string) string
- func (c Context) Querys(name string) []string
- func (c Context) ReadBody() (body []byte, err error)
- func (c Context) ReadJSON(v any) error
- func (c Context) RealIp() string
- func (c Context) Redirect(url string)
- func (c Context) Request() *http.Request
- func (c Context) RequestHeader() http.Header
- func (c Context) RequestWrite(w io.Writer) error
- func (c Context) Response() w
- func (c Context) SaveUpload(dstPath string, fields ...string) (h *multipart.FileHeader, hash string, err error)
- func (c Context) Scheme() string
- func (c Context) SetContentType(contentType string)
- func (c Context) Status(status int)
- func (c Context) Template(name string, model any)
- func (c Context) Write(b []byte) (int, error)
- func (c Context) WriteHeader(s int)
- type ContextMw
- type HandlerContext
- type Jwt
- type M
- type Middleware
- type Mux
- type Params
- type Route
- type Router
- type Routes
- type Simple
- type TemplateContext
Constants ¶
View Source
const ( HeaderXForwardedFor = "X-Forwarded-For" HeaderXRealIP = "X-Real-Ip" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXForwardedProtocol = "X-Forwarded-Protocol" HeaderXForwardedSsl = "X-Forwarded-Ssl" HeaderXUrlScheme = "X-Url-Scheme" HeaderContentType = "Content-Type" HeaderAuthorization = "Authorization" ContentTypeJSON = "application/json; charset=utf-8" ContentTypeHTML = "text/html; charset=utf-8" ContentTypePlain = "text/plain; charset=utf-8" )
View Source
const RouteTag = `group:"routes"`
Variables ¶
View Source
var ( Recoverer = middleware.Recoverer Logger = middleware.Logger NewMux = chi.NewMux )
View Source
var ( StatusCtxKey = &ctxKey{"Status"} DBCtxKey = &ctxKey{"DB"} JwtCtxKey = &ctxKey{"Jwt"} CtxKey = &ctxKey{"Ctx"} WriterKey = &ctxKey{"Writer"} UIDKey = &ctxKey{"UID"} TokenKey = &ctxKey{"Token"} )
View Source
var ErrTokenMalformed = jwt.ErrTokenMalformed
Functions ¶
func PrintRoute ¶
func PrintRoute(r Routes)
func ResolveHandler ¶
func ResolvePattern ¶
func ServeHTTPS ¶
func SetTemplateFs ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func GetContext ¶
func (Context) ClaimsValue ¶
func (Context) FormFile ¶
func (c Context) FormFile(fields ...string) (h *multipart.FileHeader)
获取第一个文件
func (Context) FormFiles ¶
func (c Context) FormFiles(fields ...string) (hs []*multipart.FileHeader)
获取所有文件
func (Context) RealIp ¶
RealIp returns the client's network address based on `X-Forwarded-For` or `X-Real-IP` request header.
func (Context) RequestHeader ¶
func (Context) SaveUpload ¶
func (c Context) SaveUpload(dstPath string, fields ...string) (h *multipart.FileHeader, hash string, err error)
保存上传文件,可以指定上传文件的字段名,如果没有指定,则保存第一个文件
func (Context) SetContentType ¶
func (Context) WriteHeader ¶
type ContextMw ¶
type ContextMw = func(next HandlerContext) HandlerContext
type HandlerContext ¶
type HandlerContext = func(Context)
type TemplateContext ¶
type TemplateContext struct {
// contains filtered or unexported fields
}
Context is the Context with which HTTP templates are executed.
func GetTemplateContext ¶
func GetTemplateContext(r *http.Request, f http.FileSystem) TemplateContext
func (*TemplateContext) NewTemplate ¶
func (c *TemplateContext) NewTemplate(tplName string) *template.Template
NewTemplate returns a new template intended to be evaluated with this context, as it is initialized with configuration from this context.
Click to show internal directories.
Click to hide internal directories.