demo

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesBytesRoutes

func BytesBytesRoutes(srv BytesBytes, opts ...gors.Option) []gors.Route

func BytesReaderRoutes

func BytesReaderRoutes(srv BytesReader, opts ...gors.Option) []gors.Route

func BytesStringRoutes

func BytesStringRoutes(srv BytesString, opts ...gors.Option) []gors.Route

func CustomBinderRenderRoutes added in v1.2.0

func CustomBinderRenderRoutes(srv CustomBinderRender, opts ...gors.Option) []gors.Route

func NotDefineRoutes added in v1.3.2

func NotDefineRoutes(srv NotDefine, opts ...gors.Option) []gors.Route

func ObjObjRoutes added in v1.3.0

func ObjObjRoutes(srv ObjObj, opts ...gors.Option) []gors.Route

func ReaderBytesRoutes

func ReaderBytesRoutes(srv ReaderBytes, opts ...gors.Option) []gors.Route

func ReaderReaderRoutes

func ReaderReaderRoutes(srv ReaderReader, opts ...gors.Option) []gors.Route

func ReaderStringRoutes

func ReaderStringRoutes(srv ReaderString, opts ...gors.Option) []gors.Route

func ServiceRoutes

func ServiceRoutes(srv Service, opts ...gors.Option) []gors.Route

func StringBytesRoutes

func StringBytesRoutes(srv StringBytes, opts ...gors.Option) []gors.Route

func StringReaderRoutes

func StringReaderRoutes(srv StringReader, opts ...gors.Option) []gors.Route

func StringStringRoutes

func StringStringRoutes(srv StringString, opts ...gors.Option) []gors.Route

Types

type AllRequestReq added in v1.5.0

type AllRequestReq struct {
	// I comment 1
	// comment 2
	I int `uri:"i"` // comment 3
	// comment 2
	I8  int8  `form:"i8"` // comment 3
	I16 int16 `header:"i16"`
	I32 int32
	I64 int64

	U   uint
	U8  uint8
	U16 uint16
	U32 uint32
	U64 uint64

	F32 float32
	F64 float64

	B  bool
	S  string
	Bs []byte `json:"bs"`
	A  [10]int

	T time.Time

	UriBindingReq    UriBindingReq
	UriBindingReqPtr *UriBindingReq
	ProtoBufReq      pb.ProtoBufReq
	ProtoBufReqPtr   *pb.ProtoBufReq

	UriBindingReqs    []UriBindingReq
	UriBindingReqPtrs []*UriBindingReq
	ProtoBufReqs      []pb.ProtoBufReq
	ProtoBufReqPtrs   []*pb.ProtoBufReq
	Page
	*TimeRage
	sql.NullByte
	*sql.NullInt32

	Avatar *multipart.FileHeader `form:"avatar"`
	// contains filtered or unexported fields
}

type AllRequestResp added in v1.5.0

type AllRequestResp struct {
}

type AsciiJSONRenderResp

type AsciiJSONRenderResp struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Auth       string    `json:"auth"`
	Address    string    `json:"address"`
	Birthday   time.Time `json:"birthday"`
	CreateTime time.Time `json:"createTime"`
	UnixTime   time.Time `json:"unixTime"`
}

type BytesBytes

type BytesBytes interface {
	// GetBytesBytes get http method, receive bytes request and send bytes response
	// @GORS @GET @Path(/Get) @BytesRender(ttt.sss)
	GetBytesBytes(context.Context, []byte) ([]byte, error)
	// PostBytesBytes post http method,  receive bytes request and send bytes response
	// @GORS @POST @Path(/Post) @BytesBinding @BytesRender(text/go)
	PostBytesBytes(context.Context, []byte) ([]byte, error)
}

BytesBytes this is bytes binding and bytes render demo this is a interface @GORS @Path(/api/BytesBytes)

type BytesReader

type BytesReader interface {
	// GetBytesReader
	// @GORS @GET @Path(/Get) @ReaderRender(video/mpeg4)
	GetBytesReader(context.Context, []byte) (tmpio.Reader, error)
	// PatchBytesReader
	// @GORS @PATCH @Path(/Patch) @BytesBinding @ReaderRender(video/mpeg4)
	PatchBytesReader(context.Context, []byte) (tmpio.Reader, error)
}

BytesReader @GORS @Path(/api/BytesReader)

type BytesString

type BytesString interface {
	// GetBytesString
	// @GORS @GET @Path(/Get) @BytesBinding @HTMLRender
	GetBytesString(context.Context, []byte) (string, error)
	// PutBytesString
	// @GORS @PUT @Path(/Put) @RedirectRender
	PutBytesString(context.Context, []byte) (string, error)
}

BytesString @GORS @Path(/api/BytesString)

type CustomBinderRender added in v1.2.0

type CustomBinderRender interface {
	// Custom
	// @GORS @POST @Path(/Custom) @CustomBinding(application/custom) @CustomRender(application/custom)
	Custom(ctx context.Context, req *CustomReq) (*CustomResp, error)
}

CustomBinderRender @GORS @Path(/api/CustomBinderRender)

type CustomReq added in v1.2.0

type CustomReq struct {
	V string
}

func (*CustomReq) Bind added in v1.2.0

func (req *CustomReq) Bind(c *gin.Context) error

type CustomResp added in v1.2.0

type CustomResp struct {
}

func (*CustomResp) Render added in v1.2.0

func (resp *CustomResp) Render(c *gin.Context)

type FormBindingReq

type FormBindingReq struct {
	ID      int64                 `uri:"id"`
	Name    string                `form:"name"`
	Auth    string                `header:"Authorization"`
	Address string                `form:"address"`
	Avatar  *multipart.FileHeader `form:"avatar"`
}

type FormBindingResp

type FormBindingResp struct {
	V int64
}

type FormMultipartBindingReq

type FormMultipartBindingReq struct {
	ID      int64                 `uri:"id"`
	Name    string                `form:"name"`
	Auth    string                `header:"Authorization"`
	Address string                `form:"address"`
	Avatar  *multipart.FileHeader `form:"avatar"`
}

type FormPostBindingReq

type FormPostBindingReq struct {
	ID      int64  `uri:"id"`
	Name    string `form:"name"`
	Auth    string `header:"Authorization"`
	Address string `form:"address"`
}

type HeaderBindingReq

type HeaderBindingReq struct {
	ID   int64  `uri:"id"`
	Name string `form:"name"`
	Auth string `header:"Authorization"`
}

type IndentedJSONRenderResp

type IndentedJSONRenderResp struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Address    string    `json:"address"`
	Birthday   time.Time `json:"birthday"`
	CreateTime time.Time `json:"createTime"`
	UnixTime   time.Time `json:"unixTime"`
}

type JSONBindingReq

type JSONBindingReq struct {
	ID      int64  `uri:"id"`
	Name    string `form:"name"`
	Auth    string `header:"Authorization"`
	Address string `json:"address"`
}

type JSONRenderResp

type JSONRenderResp struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Auth       string    `json:"auth"`
	Address    string    `json:"address"`
	Birthday   time.Time `json:"birthday"`
	CreateTime time.Time `json:"createTime"`
	UnixTime   time.Time `json:"unixTime"`
}

type JsonpJSONRenderResp

type JsonpJSONRenderResp struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Auth       string    `json:"auth"`
	Address    string    `json:"address"`
	Birthday   time.Time `json:"birthday"`
	CreateTime time.Time `json:"createTime"`
	UnixTime   time.Time `json:"unixTime"`
}

type MethodReq

type MethodReq struct {
	ID int `uri:"id"`
}

type MethodResp

type MethodResp struct {
	V int `json:"v,omitempty"`
}

type MsgPackBindingReq

type MsgPackBindingReq struct {
	ID      int64  `uri:"id"`
	Name    string `form:"name"`
	Auth    string `header:"Authorization"`
	Address string
}

type MsgPackRenderResp

type MsgPackRenderResp struct {
	ID         int64
	Name       string
	Auth       string
	Address    string
	Birthday   time.Time
	CreateTime time.Time
	UnixTime   time.Time
}

type NotDefine added in v1.3.2

type NotDefine interface {
	String(context.Context, string) (string, error)
	Bytes(context.Context, []byte) ([]byte, error)
	Reader(context.Context, io.Reader) (io.Reader, error)
	NotDefine(context.Context, *NotDefineReq) (*NotDefineResp, error)
}

type NotDefineReq added in v1.3.2

type NotDefineReq struct {
	ID int `uri:"id"`
}

type NotDefineResp added in v1.3.2

type NotDefineResp struct {
	V int `json:"v,omitempty"`
}

type ObjObj added in v1.3.0

type ObjObj interface {

	// AllRequest is http api
	// @GORS @GET @Path(/all/:id/user/:user) @UriBinding @UriBinding @QueryBinding @HeaderBinding @JSONBinding @JSONRender
	AllRequest(context.Context, *AllRequestReq) (*AllRequestResp, error)

	// UriBindingIndentedJSONRender
	// @GORS @GET @Path(/UriBindingIndentedJSONRender/:id) @UriBinding @IndentedJSONRender
	UriBindingIndentedJSONRender(context.Context, *UriBindingReq) (*IndentedJSONRenderResp, error)

	// QueryBindingSecureJSONRender
	// @GORS @GET @Path(/QueryBindingSecureJSONRender/:id) @UriBinding @QueryBinding @SecureJSONRender
	QueryBindingSecureJSONRender(context.Context, *QueryBindingReq) (*SecureJSONRenderResp, error)

	// HeaderBindingJsonpJSONRender
	// @GORS @GET @Path(/HeaderBindingJsonpJSONRender/:id) @UriBinding @QueryBinding @HeaderBinding @JSONPJSONRender
	HeaderBindingJsonpJSONRender(context.Context, *HeaderBindingReq) (*JsonpJSONRenderResp, error)

	// JSONBindingJSONRender
	// @GORS @POST @Path(/JSONBindingJSONRender/:id) @UriBinding @QueryBinding @HeaderBinding @JSONBinding @JSONRender
	JSONBindingJSONRender(context.Context, *JSONBindingReq) (*JSONRenderResp, error)
	// XMLBindingXMLRender
	// @GORS @PATCH @Path(/XMLBindingXMLRender/:id) @UriBinding @QueryBinding @HeaderBinding  @XMLBinding @XMLRender
	XMLBindingXMLRender(context.Context, *XMLBindingReq) (*XMLRenderResp, error)

	// FormBindingJSONRender
	// @GORS @POST @Path(/FormBindingJSONRender/:id) @UriBinding @HeaderBinding @FormBinding @JSONRender
	FormBindingJSONRender(context.Context, *FormBindingReq) (*JSONRenderResp, error)

	// FormPostBindingPureJSONRender
	// @GORS @POST @Path(/FormPostBindingPureJSONRender/:id) @UriBinding @QueryBinding @HeaderBinding @FormPostBinding @PureJSONRender
	FormPostBindingPureJSONRender(context.Context, *FormPostBindingReq) (*PureJSONRenderResp, error)

	// FormMultipartBindingAsciiJSONRender
	// @GORS @POST @Path(/FormMultipartBindingAsciiJSONRender/:id)  @FormMultipartBinding @UriBinding @QueryBinding @HeaderBinding @AsciiJSONRender
	FormMultipartBindingAsciiJSONRender(context.Context, *FormMultipartBindingReq) (*AsciiJSONRenderResp, error)

	// ProtoBufBindingProtoBufRender
	// @GORS @PUT @Path(/ProtoBufBindingProtoBufRender) @ProtoBufBinding @ProtoBufRender
	ProtoBufBindingProtoBufRender(context.Context, *pb.ProtoBufReq) (*pb.ProtoBufResp, error)

	// MsgPackBindingMsgPackRender
	// @GORS @DELETE @Path(/MsgPackBindingMsgPackRender) @MsgPackBinding @MsgPackRender
	MsgPackBindingMsgPackRender(context.Context, *MsgPackBindingReq) (*MsgPackRenderResp, error)

	// YAMLBindingYAMLRender
	// @GORS @DELETE @Path(/YAMLBindingYAMLRender/:id) @UriBinding @QueryBinding @HeaderBinding @YAMLBinding @YAMLRender
	YAMLBindingYAMLRender(context.Context, *YAMLBindingReq) (*YAMLRenderResp, error)

	// TOMLBindingTOMLRender
	// @GORS @PUT @Path(/TOMLBindingTOMLRender/:id) @UriBinding @QueryBinding @HeaderBinding @TOMLBinding @TOMLRender
	TOMLBindingTOMLRender(context.Context, *TOMLBindingReq) (*TOMLRenderResp, error)

	// ProtoJSONBindingProtoJSONRender
	// @GORS @PUT @Path(/ProtoJSONBindingProtoJSONRender) @ProtoJSONBinding @ProtoJSONRender
	ProtoJSONBindingProtoJSONRender(context.Context, *pb.ProtoBufReq) (*pb.ProtoBufResp, error)
}

ObjObj @GORS @Path(/api/ObjObj)

type Page added in v1.5.0

type Page struct {
	Num  int `json:"num"`
	Size int `json:"size"`
}

type PureJSONRenderResp

type PureJSONRenderResp struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Auth       string    `json:"auth"`
	Address    string    `json:"address"`
	Birthday   time.Time `json:"birthday"`
	CreateTime time.Time `json:"createTime"`
	UnixTime   time.Time `json:"unixTime"`
}

type QueryBindingReq

type QueryBindingReq struct {
	ID   int64  `uri:"id"`
	Name string `form:"name"`
}

type ReaderBytes

type ReaderBytes interface {
	// GetReaderBytes
	// @GORS @GET @Path(/Get) @ReaderBinding @BytesRender
	GetReaderBytes(context.Context, tmpio.Reader) ([]byte, error)
	// PostReaderBytes
	// @GORS @POST @Path(/Post) @BytesRender(text/go)
	PostReaderBytes(context.Context, tmpio.Reader) ([]byte, error)
}

ReaderBytes @GORS @Path(/api/ReaderBytes)

type ReaderReader

type ReaderReader interface {
	// GetReaderReader
	// @GORS @GET @Path(/Get) @ReaderRender
	GetReaderReader(context.Context, io.Reader) (io.Reader, error)
	// HeadReaderReader
	// @GORS @HEAD @Path(/head) @ReaderBinding @ReaderRender(video/mp4)
	HeadReaderReader(context.Context, io.Reader) (io.Reader, error)
	// GetJSONReader
	// @GORS @Get @Path(/get/json) @JSONBinding @ReaderRender(video/mp4)
	GetJSONReader(context.Context, *gors.Empty) (io.Reader, error)
}

ReaderReader @GORS @Path(/api/ReaderReader)

type ReaderString

type ReaderString interface {
	// GetReaderString
	// @GORS @GET @Path(/Get) @TextRender
	GetReaderString(context.Context, io.Reader) (string, error)
	// PostReaderString
	// @GORS @POST @Path(/Post) @StringRender(text/go)
	PostReaderString(context.Context, io.Reader) (string, error)
}

ReaderString @GORS @Path(/api/ReaderString)

type SecureJSONRenderResp

type SecureJSONRenderResp struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Address    string    `json:"address"`
	Birthday   time.Time `json:"birthday"`
	CreateTime time.Time `json:"createTime"`
	UnixTime   time.Time `json:"unixTime"`
}

type Service

type Service interface {
	// Method
	// @GORS @GET @Path(/method/:id) @UriBinding @JSONRender
	Method(context.Context, *MethodReq) (*MethodResp, error)
}

Service @GORS @Path(/api) @Path(/v1)

type StringBytes

type StringBytes interface {
	// GetStringBytes
	// @GORS @GET @Path(/Get) @BytesRender
	GetStringBytes(context.Context, string) ([]byte, error)
	// OptionsStringBytes
	// @GORS @OPTIONS @Path(/Options) @BytesRender
	OptionsStringBytes(context.Context, string) ([]byte, error)
}

StringBytes @GORS @Path(/api/StringBytes)

type StringReader

type StringReader interface {
	// GetStringRender
	// @GORS @GET @Path(/Get) @ReaderRender(video/mpeg4)
	GetStringRender(context.Context, string) (tmpio.Reader, error)
	// OptionsStringReader
	// @GORS @OPTIONS @Path(/Options) @ReaderRender(video/mpeg4)
	OptionsStringReader(context.Context, string) (tmpio.Reader, error)
}

StringReader @GORS @Path(/api/StringReader)

type StringString

type StringString interface {
	// GetStringString
	// @GORS @GET @Path(/Get) @StringRender(text/go)
	GetStringString(context.Context, string) (string, error)
	// PatchStringString
	// @GORS @PATCH @Path(/Patch) @StringRender(application/java) @StringRender(application/go)
	PatchStringString(context.Context, string) (string, error)
}

StringString @GORS @Path(/api/StringString)

type TOMLBindingReq

type TOMLBindingReq struct {
	ID      int64  `uri:"id"`
	Name    string `form:"name"`
	Auth    string `header:"Authorization"`
	Address string `toml:"address"`
}

type TOMLRenderResp

type TOMLRenderResp struct {
	ID         int64     `toml:"id"`
	Name       string    `toml:"name"`
	Auth       string    `toml:"auth"`
	Address    string    `toml:"address"`
	Birthday   time.Time `toml:"birthday"`
	CreateTime time.Time `toml:"createTime"`
	UnixTime   time.Time `toml:"unixTime"`
}

type TimeRage added in v1.5.0

type TimeRage struct {
	Start time.Time `json:"start"`
	End   time.Time `json:"end"`
}

type UriBindingReq

type UriBindingReq struct {
	ID int64 `uri:"id"`
}

type XMLBindingReq

type XMLBindingReq struct {
	ID      int64  `uri:"id"`
	Name    string `form:"name"`
	Auth    string `header:"Authorization"`
	Address string `xml:"address"`
}

type XMLRenderResp

type XMLRenderResp struct {
	ID         int64     `xml:"id"`
	Name       string    `xml:"name"`
	Auth       string    `xml:"auth"`
	Address    string    `xml:"address"`
	Birthday   time.Time `xml:"birthday"`
	CreateTime time.Time `xml:"createTime"`
	UnixTime   time.Time `xml:"unixTime"`
}

type YAMLBindingReq

type YAMLBindingReq struct {
	ID      int64  `uri:"id"`
	Name    string `form:"name"`
	Auth    string `header:"Authorization"`
	Address string `yaml:"address"`
}

type YAMLRenderResp

type YAMLRenderResp struct {
	ID         int64     `yaml:"id"`
	Name       string    `yaml:"name"`
	Auth       string    `yaml:"auth"`
	Address    string    `yaml:"address"`
	Birthday   time.Time `yaml:"birthday"`
	CreateTime time.Time `yaml:"createTime"`
	UnixTime   time.Time `yaml:"unixTime"`
}

Jump to

Keyboard shortcuts

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