api

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause Imports: 10 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 {
	// contains filtered or unexported fields
}

func New404Api added in v1.4.1

func New404Api() *Api

func NewApi

func NewApi(params *NewApiParamsType) *Api

func (*Api) ControllerFunc added in v1.4.1

func (api *Api) ControllerFunc() ApiHandlerType

func (*Api) Description

func (api *Api) Description() string

func (*Api) IsIgnoreRootPath added in v1.4.1

func (api *Api) IsIgnoreRootPath() bool

func (*Api) Method

func (api *Api) Method() api_session.ApiMethod

func (*Api) ParamType

func (api *Api) ParamType() string

func (*Api) Params

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

func (*Api) Path

func (api *Api) Path() string

func (*Api) Strategies

func (api *Api) Strategies() []StrategyData

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 NewApiParamsType added in v1.4.1

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

type ReturnHookFuncType

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

type StrategyData added in v1.3.1

type StrategyData struct {
	Strategy api_strategy.IApiStrategy
	Disable  bool
}

Directories

Path Synopsis
type module

Jump to

Keyboard shortcuts

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