Documentation ¶
Index ¶
Constants ¶
View Source
const ( ContentTypeDownload = `application/force-download` //文件下载 ContentTypeDefault = `text/plain; charset=utf-8` //文本 ContentTypeJSON = `application/json; charset=utf-8` //json ContentTypeHTML = `text/html; charset=utf-8` //HTML ContentTypeXJS = `application/x-javascript;charset=utf-8` //JavaScript ContentTypeJS = `text/javascript; charset=utf-8` //JavaScript ContentTypeCSS = `text/css; charset=utf-8` //CSS ContentTypeImageJPEG = `image/jpeg` //jpeg图片 ContentTypeImageJPG = `image/jpeg` //jpg图片 ContentTypeImagePNG = `image/png` //png图片 ContentTypeImageWEBP = `image/webp` //webp图片 ContentTypeImageGIF = `image/gif` //gif图片 ContentTypeImageICON = `image/x-icon` //icon图标 ContentTypeImageOctetStream = `application/octet-stream` //八位字节流 )
View Source
const ( TagQuery = `url` TagForm = `form` TagHeaders = `header` TagParams = `param` )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context interface { // Writer 原生http.ResponseWriter Writer() http.ResponseWriter // Request 原生*http.Request Request() *http.Request // SetStatusCode 设置响应状态码 SetStatusCode(code int) // Values 上下文的key-value Values() Values // Req 与请求有关信息解析与绑定 Req() Request // Stop 中间件里面使用,停止后续步骤的执行。 Stop() // HeaderClean 清空已设置的响应头 HeaderClean() // HeaderSet 设置响应头 HeaderSet(key, value string) // HeaderDel 删除已设置的响应头 HeaderDel(key string) // HeaderGet 获取已设置的响应头 HeaderGet(key string) string // WriteClean 清空已写入的响应体 WriteClean() // Write 写入响应体 Write(body []byte) // WriteString 写入响应体 WriteString(body string) // WriteJSON 写入响应体,将obj进行json编码后写入响应体 WriteJSON(obj any) (int, error) // CWrite 写入响应体并且设置响应状态码 CWrite(code int, body []byte) // CWriteString 写入响应体并且设置响应状态码 CWriteString(code int, body string) // CWriteJSON 写入响应体并且设置响应状态码,将obj进行json编码后写入响应体 CWriteJSON(code int, obj any) (int, error) // ResponseBody 返回当前已写入的响应体所有内容 ResponseBody() string // contains filtered or unexported methods }
type HandlerFunc ¶
type HandlerFunc func(Context)
type HandlerFuncList ¶
type HandlerFuncList interface { Get(HandlerFunc) HandlerFuncList Head(HandlerFunc) HandlerFuncList Post(HandlerFunc) HandlerFuncList Put(HandlerFunc) HandlerFuncList Patch(HandlerFunc) HandlerFuncList Delete(HandlerFunc) HandlerFuncList Connect(HandlerFunc) HandlerFuncList Options(HandlerFunc) HandlerFuncList Trace(HandlerFunc) HandlerFuncList Build() HandlerFunc }
type Middleware ¶
type Middleware interface { Clone() Middleware Append(HandlerFunc) Use(HandlerFunc) HandlerFunc(HandlerFunc) http.HandlerFunc Any(HandlerFunc) http.HandlerFunc Get(HandlerFunc) http.HandlerFunc Post(HandlerFunc) http.HandlerFunc Delete(HandlerFunc) http.HandlerFunc Put(HandlerFunc) http.HandlerFunc Head(HandlerFunc) http.HandlerFunc Patch(HandlerFunc) http.HandlerFunc Connect(HandlerFunc) http.HandlerFunc Options(HandlerFunc) http.HandlerFunc Trace(HandlerFunc) http.HandlerFunc MethodList() HandlerFuncList // contains filtered or unexported methods }
func NewMiddleware ¶
func NewMiddleware() Middleware
type Request ¶
type Request interface { // Method 请求方法 Method() string // GetIP 获取相对真实的IP GetIP() string // GetUrlPath 获取请求路径 GetUrlPath() string // GetBody 获取请求体 GetBody() ([]byte, error) // ReadQuery 读取url的查询参数,并且绑定到obj ReadQuery(obj any) error // ReadAllForm 读取url的查询参数和pos表单,并且绑定到obj ReadAllForm(obj any) error // ReadPostForm 读取post表单的查询参数,并且绑定到obj ReadPostForm(obj any) error // ReadHeaders 读取请求头,并且绑定到obj ReadHeaders(obj any) error // ReadBody 读取请求体,并且绑定到obj;支持post表单、json。 ReadBody(obj any) error // ReadJSON 读取请求头,并且json解码到obj; ReadJSON(obj any) error // ReadQueryV 读取url的查询参数,并且绑定到obj;最后进行表单校验。 ReadQueryV(obj any) error // ReadAllFormV 读取url的查询参数和pos表单,并且绑定到obj;最后进行表单校验。 ReadAllFormV(obj any) error // ReadPostFormV 读取post表单的查询参数,并且绑定到obj;最后进行表单校验。 ReadPostFormV(obj any) error // ReadHeadersV 读取请求头,并且绑定到obj;最后进行表单校验。 ReadHeadersV(obj any) error // ReadBodyV 读取请求体,并且绑定到obj;支持post表单、json;最后进行表单校验。 ReadBodyV(obj any) error // ReadJSONV 读取请求头,并且json解码到obj;最后进行表单校验。 ReadJSONV(obj any) error // Validator 表单校验 Validator(obj any) error // contains filtered or unexported methods }
type Resp ¶
type Values ¶
type Values interface { Set(string, any) Get(string, ...any) (any, bool) GetString(string, ...string) (string, bool) GetInt(string, ...int) (int, bool) GetInt8(string, ...int8) (int8, bool) GetInt16(string, ...int16) (int16, bool) GetInt32(string, ...int32) (int32, bool) GetInt64(string, ...int64) (int64, bool) GetUint(string, ...uint) (uint, bool) GetUint8(string, ...uint8) (uint8, bool) GetUint16(string, ...uint16) (uint16, bool) GetUint32(string, ...uint32) (uint32, bool) GetUint64(string, ...uint64) (uint64, bool) GetFloat32(string, ...float32) (float32, bool) GetFloat64(string, ...float64) (float64, bool) GetBool(string, ...bool) (bool, bool) GetTime(string, ...time.Time) (time.Time, bool) }
Values 上下文存储信息 此接口的设计,参考 github.com/kataras/iris/v12/core/memstore 。
Click to show internal directories.
Click to hide internal directories.