api

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: BSD-3-Clause Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapJson added in v1.0.2

func WrapJson(methodController map[string]*Api) func(response http.ResponseWriter, request *http.Request)

* wrap api处理器. 一个path一个,方法内分别处理method

Types

type Api

type Api struct {
	Description            string                // api描述
	Path                   string                // api路径
	IgnoreRootPath         bool                  // api路径是否忽略根路径
	IgnoreGlobalStrategies bool                  // 是否跳过全局策略
	Method                 api_session.ApiMethod // api方法
	Strategies             []_type.StrategyData  // api前置处理策略,不包含全局策略
	Params                 interface{}           // api参数
	Return                 interface{}           // api返回值
	Controller             ApiHandlerType        // api业务处理器
	ParamType              string                // 参数类型。默认 application/json,可选 multipart/form-data,空表示都支持
	ReturnHookFunc         ReturnHookFuncType    // 返回前的处理函数
}

func (*Api) GetDescription

func (api *Api) GetDescription() string

func (*Api) GetParamType

func (api *Api) GetParamType() string

func (*Api) GetParams

func (api *Api) GetParams() interface{}

type ApiHandlerType

type ApiHandlerType func(apiSession _type2.IApiSession) (interface{}, *go_error.ErrorInfo)

type ApiResult

type ApiResult struct {
	Msg  string      `json:"msg"`
	Code uint64      `json:"code"`
	Data interface{} `json:"data"`
}

type ReturnHookFuncType

type ReturnHookFuncType func(apiSession _type2.IApiSession, apiResult *ApiResult) (interface{}, *go_error.ErrorInfo)

Directories

Path Synopsis
type module

Jump to

Keyboard shortcuts

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