ghertz

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CookieDeleteMe     = "DeleteMe"
	CookieDeleteMaxAge = 0
	CookieDeleteVal    = ""
)

Variables

View Source
var CookieExpireDelete = time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)

Functions

func CheckHeaderParams

func CheckHeaderParams(name string, v *string, ctx *app.RequestContext) bool

func CheckHeaderParamsWithErrorMsg

func CheckHeaderParamsWithErrorMsg(name string, v *string, errorMsg string, ctx *app.RequestContext) bool

func CheckParamsWithErrorMsg

func CheckParamsWithErrorMsg(name string, str string, v *string, errorMsg string, ctx *app.RequestContext) bool

func CheckPostFormParams

func CheckPostFormParams(name string, v *string, ctx *app.RequestContext) bool

func CheckPostFormParamsWithErrorMsg

func CheckPostFormParamsWithErrorMsg(name string, v *string, errorMsg string, ctx *app.RequestContext) bool

func CheckQueryParams

func CheckQueryParams(name string, v *string, ctx *app.RequestContext) bool

func CheckQueryParamsWithErrorMsg

func CheckQueryParamsWithErrorMsg(name string, v *string, errorMsg string, ctx *app.RequestContext) bool

func ClearCookie

func ClearCookie(ctx *app.RequestContext, domain string, path string, keys ...string)

del cookie if len(keys)==0 this function will delete all cookies

func GetCookie

func GetCookie(name string, ctx *app.RequestContext) string

func GetHeader

func GetHeader(ctx *app.RequestContext, key string) string

func NewServer

func NewServer(options gServer.Options, routerProvider func(engine *server.Hertz), middlewares ...app.HandlerFunc) gServer.Server

func PostFormArray

func PostFormArray(ctx *app.RequestContext, name string) []string

func QueryArray

func QueryArray(ctx *app.RequestContext, name string) []string

func SetCookie

func SetCookie(c cookie.Cookie, ctx *app.RequestContext)

func ShouldBind

func ShouldBind(ctx *app.RequestContext, obj any) error

tag名称及使用方法 path 绑定 url 上的路径参数,相当于 hertz 路由{:param}或{*param}中拿到的参数。例如:如果定义的路由为:/v:version/example,可以把 path 的参数指定为路由参数:path:"version",此时,url: http://127.0.0.1:8888/v1/example,可以绑定path参数"1" form 绑定请求的 body 内容。content-type -> multipart/form-data 或 application/x-www-form-urlencoded,绑定 form 的 key-value query 绑定请求的 query 参数 cookie 绑定请求的 cookie 参数 header 绑定请求的 header 参数 json 绑定请求的 body 内容 content-type -> application/json,绑定 json 参数 raw_body 绑定请求的原始 body(bytes),绑定的字段名不指定,也能绑定参数。(注:raw_body 绑定优先级最低,当指定多个 tag 时,一旦其他 tag 成功绑定参数,则不会绑定 body 内容。) 参数绑定优先级 path > form > query > cookie > header > json > raw_body

Types

type Server

type Server struct {
	Svr     *server.Hertz
	Options gServer.Options
}

func (*Server) Run

func (server *Server) Run(graceful ...func())

func (*Server) Shutdown

func (server *Server) Shutdown()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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