STNet

package
v0.0.0-...-7558d7e Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JSON = iota
	STRING
	FILE
	XML
)
View Source
const (
	PARAMPORSEERROR     = "0" //客户端传参进入服务器------->传参错误
	PARAMUNMARSHALERROR = "1" //服务器回传时-------------->序列化失败
)
View Source
const HandlerName = "Handler"
View Source
const IParameterName = "IParameter"
View Source
const IResultName = "IResult"
View Source
const OP = "op"
View Source
const ResponseTypeName = "ResponseType"

Variables

This section is empty.

Functions

func Register

func Register(op string, request IHandler)

注册路由,根据路由来设置对应的接收参数和返回值

func RegisterFunc

func RegisterFunc(op string, request IHandler, method func() interface{})

注册路由,根据路由来设置对应的接收参数和返回值

func RegisterFuncByName

func RegisterFuncByName(op string, request IHandler, methodName string)

注册路由,根据路由来设置对应的接收参数和返回值

func RegisterOver

func RegisterOver()

func RequestRouter

func RequestRouter(c *gin.Context)

根据url中的op字段进行路由,客户端传入参数转化为用户定义的结构体进行回调,返回值将返回至客户端,根据用户的返回值类型不同进行不同的处理 如需返回特殊的如XML、FILE两种形式,需继承IResult,并对ResponseType进行赋值,设置返回客户端的数据格式

Types

type FILE_Message

type FILE_Message struct {
	IResult
	FilePath string `json:"filepath"`
}

如果返回客户端为FILE,请使用该结构体

type IParameter

type IParameter struct {
	// contains filtered or unexported fields
}

如果需要进行参数验证,必须继承该结构体

func (*IParameter) Count

func (ip *IParameter) Count(t Type.TableType) Type.TableType

func (*IParameter) CountAll

func (ip *IParameter) CountAll(t Type.DBOperation) Type.TableType

func (*IParameter) Get

func (ip *IParameter) Get() map[string]*iParameterVer

func (*IParameter) JsonSring

func (ip *IParameter) JsonSring() string

type IResult

type IResult struct {
	ResponseType ResponseType
}

要求返回值结构体里必须有这个,才可以自动解析出给客户端的数据格式

func (*IResult) SetResponseType

func (result *IResult) SetResponseType(t ResponseType)

type Request

type Request struct {
	// contains filtered or unexported fields
}

func (*Request) DealReq

func (req *Request) DealReq(r *http.Request) error

对客户端来源数据进行解析,这样子只支持了Content-Type为application/json的数据

func (*Request) ParseParam

func (req *Request) ParseParam(param IHandler, parameter IParameter, handlerName string) error

根据设定的传参结构体及返回值的结构体及返回客户端的数据格式,进行自动解析

type ResponseCode

type ResponseCode string

type ResponseType

type ResponseType int

type State_Message

type State_Message struct {
	IResult
	State   bool   `json:"state"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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