Documentation ¶
Index ¶
- Variables
- func AddCustomContextGetReturn(key string, ret interface{})
- func AddCustomFormValueReturn(name string, str string)
- func AddCustomGetReturn(key string, ret interface{})
- func AddCustomGoTypeToJSONType(goType string, jsonType string)
- func AddCustomQueryParamReturn(name string, str string)
- func FillEmptyValuesOfStruct(structVal reflect.Value, intVal int64, uintVal uint64, floatVal float64, ...)
- func FillStruct(structPtr interface{})
- func ModifyFileHeaderContent(fh *multipart.FileHeader, content []byte)
- func NewAPICollector() *apiCollector
- func SetContextGetParams(params ...Param)
- func SetFormParams(params ...Param)
- func SetGloablResponseJSONParams(params ...Param)
- func SetIgnoredResponseJSONParams(params ...Param)
- func SetPostJSONParams(params ...Param)
- func SetQueryParams(params ...Param)
- func SetResponseJSONParams(params ...Param)
- type ContextJSON
- type GroupInterface
- type GroupInterfaceFull
- type Param
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // c.JSON 时,若传入的数据有零值,可以将其递归地填充为非零值(数值填充成 1,字符串填充成 "1",布尔值依然为 false) FillZeroValue = false SkipGen = "[skip gen]" // 当返回值不为 200 时,打印 warning 信息 WarningWhenNotStatusOK = true // 字段缺少描述时打印 warning 信息 WarningMissingFields = true )
杂项配置
View Source
var ( DefaultMarkdownHeader = `# 接口文档 ## HTTP 接口` DefaultFormFileDesc = "上传的文件" )
Markdown 相关配置
View Source
var ( DefaultCookie = http.Cookie{Value: "1"} DefaultGetReturn interface{} = 1 DefaultQueryParamReturn = "1" DefaultFormValueReturn = "1" DefaultMultipartFileHeader = multipart.FileHeader{Filename: "example.txt", Size: 1} DefaultMultipartFileHeaderContent = []byte("A") )
默认 echo 操作返回值 若要精确设置,见下方的 AddCustomGetReturn 等
View Source
var ( EmptyContextJSONer = &emptyContextJSON{} ErrorCodeContextJSONer = &errorCodeContextJSON{1000} )
View Source
var (
DefaultTime = time.Date(2010, 11, 22, 15, 16, 17, 0, time.Local)
)
Functions ¶
func AddCustomContextGetReturn ¶
func AddCustomContextGetReturn(key string, ret interface{})
func AddCustomGetReturn ¶
func AddCustomGetReturn(key string, ret interface{})
func FillEmptyValuesOfStruct ¶
func FillEmptyValuesOfStruct(structVal reflect.Value, intVal int64, uintVal uint64, floatVal float64, stringVal string)
只能修改 public 字段
func ModifyFileHeaderContent ¶
func ModifyFileHeaderContent(fh *multipart.FileHeader, content []byte)
func SetContextGetParams ¶
func SetContextGetParams(params ...Param)
func SetFormParams ¶
func SetFormParams(params ...Param)
func SetGloablResponseJSONParams ¶
func SetGloablResponseJSONParams(params ...Param)
globalResponseJSONParams 为所有返回的 JSON 都会有的字段 同时会设置 ignoredResponseJSONParams
func SetIgnoredResponseJSONParams ¶
func SetIgnoredResponseJSONParams(params ...Param)
解析返回的 JSON 时,忽略这些字段
func SetPostJSONParams ¶
func SetPostJSONParams(params ...Param)
func SetQueryParams ¶
func SetQueryParams(params ...Param)
func SetResponseJSONParams ¶
func SetResponseJSONParams(params ...Param)
Types ¶
type ContextJSON ¶
type ContextJSON interface { BeforeJSON(code int, i interface{}) AfterJSON(code int, i interface{}) }
var (
ContextJSONer ContextJSON = ErrorCodeContextJSONer
)
type GroupInterface ¶
type GroupInterface interface { Group(prefix string, middleware ...echo.MiddlewareFunc) GroupInterface Use(middleware ...echo.MiddlewareFunc) GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route }
type GroupInterfaceFull ¶
type GroupInterfaceFull interface { Use(m ...echo.MiddlewareFunc) CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route Any(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route Match(methods []string, path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) []*echo.Route Group(prefix string, m ...echo.MiddlewareFunc) GroupInterface Static(prefix, root string) File(path, file string) Add(method, path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route }
由于 Group 方法返回的类型和调用者相同,只能将所有方法提出到一个 interface
Source Files ¶
Click to show internal directories.
Click to hide internal directories.