Documentation ¶
Index ¶
- Variables
- func AnalyzeStructParams(requestStruct interface{}, funcArgs *RequestParams, params *RequestParams, ...)
- func Any(pattern string, handlers ...martini.Handler)
- func BindRouter(router martini.Router)
- func Delete(pattern string, handlers ...martini.Handler)
- func Get(pattern string, handlers ...martini.Handler)
- func GetAPINameByPattern(pattern string, repl func(string) string) string
- func GetFuncNameByPattern(pattern string, repl func(string) string) string
- func GetPathByPattern(pattern string, repl func(string) string) string
- func Head(pattern string, handlers ...martini.Handler)
- func Options(pattern string, handlers ...martini.Handler)
- func Patch(pattern string, handlers ...martini.Handler)
- func Post(pattern string, handlers ...martini.Handler)
- func Put(pattern string, handlers ...martini.Handler)
- func Regist(method string, pattern string, handlers ...martini.Handler)
- func RegistedApiMap() map[string]apiConfig
- func RegistedSortedApiMap() []apiConfig
- func ReplaceContinuousNewLine(src string, repl string) string
- func Reset()
- func TailComma(idx int, params RequestParams) string
- func TrimReplaceStartSpace(src string, repl string) string
- func TrimStartSpaceEmptyLine(src string) (result string, err error)
- func WithInfo(info interface{}) *apiOrm
- type ExtraStruct
- type ExtraStructs
- type RequestInfo
- type RequestParam
- type RequestParams
Constants ¶
This section is empty.
Variables ¶
var (
ErrorAPIRegisted2 = errutil.NewFactory("API already registed for method=%q pattern=%1")
)
errors
var (
ErrorRequestParamNotFound1 = errutil.NewFactory("param %q not found in request map")
)
errors
Functions ¶
func AnalyzeStructParams ¶
func AnalyzeStructParams( requestStruct interface{}, funcArgs *RequestParams, params *RequestParams, extraStructs *ExtraStructs, )
AnalyzeStructParams analyze requestStruct fields and fill funcArgs/params
func BindRouter ¶
BindRouter bind all registed apis to martini router
func GetAPINameByPattern ¶
GetAPINameByPattern return API name by analyze pattern
func GetFuncNameByPattern ¶
GetFuncNameByPattern return API name by analyze pattern
func GetPathByPattern ¶
GetPathByPattern return api path by analyze pattern
func RegistedApiMap ¶
func RegistedApiMap() map[string]apiConfig
RegistedApiMap return all registed API
func RegistedSortedApiMap ¶
func RegistedSortedApiMap() []apiConfig
RegistedSortedApiMap return all registed API sorted
func ReplaceContinuousNewLine ¶
ReplaceContinuousNewLine replace continuous newline
func TailComma ¶
func TailComma(idx int, params RequestParams) string
TailComma return "," if idx is the last of params
func TrimReplaceStartSpace ¶
TrimReplaceStartSpace trim space and replace start space with repl per line
func TrimStartSpaceEmptyLine ¶
TrimStartSpaceEmptyLine remove empty line with start space
Types ¶
type ExtraStruct ¶
type ExtraStruct struct { FieldName string FieldType reflect.Type Params RequestParams }
ExtraStruct contain struct name, type info, and params info
type ExtraStructs ¶
type ExtraStructs []*ExtraStruct
ExtraStructs is slice type of ExtraStruct
func (*ExtraStructs) Upsert ¶
func (p *ExtraStructs) Upsert(param string, paramType reflect.Type) *ExtraStruct
Upsert append ExtraStruct to ExtraStructs if not exist
type RequestInfo ¶
type RequestInfo struct { APIName string FuncName string // FuncName := APIName with version suffix FuncArgs RequestParams Path string Params RequestParams ExtraStructs ExtraStructs }
RequestInfo contains request function name, params
func AnalyzeRequestStruct ¶
func AnalyzeRequestStruct( pattern string, requestStruct interface{}, replFuncName func(param string) string, replPath func(param string) string, ) (reqinfo RequestInfo)
AnalyzeRequestStruct analyze request struct object, produce request struct map struct field with tag `apijs:"inherit"` will extend the field arguments repl used for custom function name generator
type RequestParam ¶
type RequestParam struct { FieldName string FieldType reflect.StructField }
RequestParam contain param name and type info
type RequestParams ¶
type RequestParams []RequestParam
RequestParams is slice type of RequestParam
func (*RequestParams) Clone ¶
func (p *RequestParams) Clone() RequestParams
Clone a new RequestParams
func (*RequestParams) Delete ¶
func (p *RequestParams) Delete(params ...string) (err error)
Delete param in RequestParams
func (*RequestParams) FieldNames ¶
func (p *RequestParams) FieldNames() (results []string)
FieldNames return field names in string slice type
func (*RequestParams) Upsert ¶
func (p *RequestParams) Upsert(param string, paramType *reflect.StructField)
Upsert append RequestParam to RequestParams if not exist