api

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouterRoot   = "root"
	RouterPrefix = "prefix"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

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

func New

func New(opts ...Option) *Api

func NewWithEngine added in v0.3.0

func NewWithEngine(server *http.Server, engine *gin.Engine, opts ...Option) *Api

func (*Api) ChooseRouter added in v0.2.2

func (api *Api) ChooseRouter(routerType string, version string) Router

func (*Api) Finish

func (api *Api) Finish() error

func (*Api) Options

func (api *Api) Options() Options

func (*Api) PrefixRouter

func (api *Api) PrefixRouter() Router

func (*Api) RootRouter

func (api *Api) RootRouter() Router

func (*Api) Start

func (api *Api) Start() error

type CacheBody added in v0.6.0

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

func (*CacheBody) Bytes added in v0.6.0

func (cacheBody *CacheBody) Bytes() []byte

func (*CacheBody) Set added in v0.6.0

func (cacheBody *CacheBody) Set(bytesBody []byte)

type Context

type Context struct {
	*gin.Context
}

func (*Context) GetBytesBody added in v0.6.0

func (c *Context) GetBytesBody() (*CacheBody, error)

func (*Context) GetFileHeaderBytes

func (c *Context) GetFileHeaderBytes(fileHeader *multipart.FileHeader) (string, []byte, error)

GetFileHeaderBytes 获取传递的文件名和文件内容

func (*Context) GetHeaders added in v0.3.0

func (c *Context) GetHeaders() map[string]string

func (*Context) GetJsonBody added in v0.6.0

func (c *Context) GetJsonBody() (*JsonBody, error)

func (*Context) GetPathParams added in v0.6.0

func (c *Context) GetPathParams() *PathPrams

func (*Context) GetQueryParams added in v0.6.0

func (c *Context) GetQueryParams() *QueryPrams

func (*Context) GetTenantInfo added in v0.4.0

func (c *Context) GetTenantInfo() TenantInfo

func (*Context) GetUserInfo added in v0.4.0

func (c *Context) GetUserInfo() UserInfo

func (*Context) SetTenantInfo added in v0.8.0

func (c *Context) SetTenantInfo(tenantInfo TenantInfo)

func (*Context) SetUserInfo added in v0.8.0

func (c *Context) SetUserInfo(userInfo UserInfo)

type Handler

type Handler func(c *Context)

Handler 请求处理函数

type JsonBody added in v0.6.0

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

func (*JsonBody) Bytes added in v0.6.0

func (jsonBody *JsonBody) Bytes() ([]byte, error)

func (*JsonBody) Delete added in v0.6.0

func (jsonBody *JsonBody) Delete(key string)

func (*JsonBody) Get added in v0.6.0

func (jsonBody *JsonBody) Get(key string) any

func (*JsonBody) Map added in v0.6.0

func (jsonBody *JsonBody) Map() map[string]any

func (*JsonBody) Set added in v0.6.0

func (jsonBody *JsonBody) Set(key string, value any)

func (*JsonBody) Unmarshal added in v0.6.0

func (jsonBody *JsonBody) Unmarshal(output any) error

type Option

type Option func(options *Options)

func WithPort

func WithPort(port string) Option

func WithUrlPrefix

func WithUrlPrefix(urlPrefix string) Option

type Options

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

func (Options) GetPort

func (options Options) GetPort() string

func (Options) GetUrlPrefix

func (options Options) GetUrlPrefix() string

type PathPrams added in v0.6.0

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

func (*PathPrams) Delete added in v0.6.0

func (pathParams *PathPrams) Delete(key string)

func (*PathPrams) Get added in v0.6.0

func (pathParams *PathPrams) Get(key string) string

func (*PathPrams) Map added in v0.6.0

func (pathParams *PathPrams) Map() map[string]string

func (*PathPrams) Set added in v0.6.0

func (pathParams *PathPrams) Set(key string, value string)

type PrefixRouter

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

func (*PrefixRouter) AddMiddlewares

func (r *PrefixRouter) AddMiddlewares(middlewares ...Handler) Router

func (*PrefixRouter) AddRoute

func (r *PrefixRouter) AddRoute(method string, relativePath string, middlewares ...Handler) Router

func (*PrefixRouter) BasePath

func (r *PrefixRouter) BasePath() string

func (*PrefixRouter) RegisterVersionedRouter

func (r *PrefixRouter) RegisterVersionedRouter(version string, middlewares ...Handler) Router

func (*PrefixRouter) Static

func (r *PrefixRouter) Static(relativePath string, root string)

func (*PrefixRouter) StaticFile

func (r *PrefixRouter) StaticFile(relativePath string, filepath string)

func (*PrefixRouter) VersionedRouter

func (r *PrefixRouter) VersionedRouter(version string) Router

type QueryPrams added in v0.6.0

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

func (*QueryPrams) Delete added in v0.6.0

func (queryParams *QueryPrams) Delete(key string)

func (*QueryPrams) Get added in v0.6.0

func (queryParams *QueryPrams) Get(key string) string

func (*QueryPrams) Map added in v0.6.0

func (queryParams *QueryPrams) Map() map[string]string

func (*QueryPrams) Set added in v0.6.0

func (queryParams *QueryPrams) Set(key string, value string)

type RootRouter

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

func (*RootRouter) AddMiddlewares

func (r *RootRouter) AddMiddlewares(middlewares ...Handler) Router

func (*RootRouter) AddRoute

func (r *RootRouter) AddRoute(method string, relativePath string, middlewares ...Handler) Router

func (*RootRouter) BasePath

func (r *RootRouter) BasePath() string

func (*RootRouter) RegisterVersionedRouter

func (r *RootRouter) RegisterVersionedRouter(version string, middlewares ...Handler) Router

func (*RootRouter) ServerHttp

func (r *RootRouter) ServerHttp(w http.ResponseWriter, req *http.Request)

func (*RootRouter) Static

func (r *RootRouter) Static(relativePath string, root string)

func (*RootRouter) StaticFile

func (r *RootRouter) StaticFile(relativePath string, filepath string)

func (*RootRouter) VersionedRouter

func (r *RootRouter) VersionedRouter(version string) Router

type Router

type Router interface {
	AddMiddlewares(middlewares ...Handler) Router
	RegisterVersionedRouter(version string, middlewares ...Handler) Router
	VersionedRouter(version string) Router
	AddRoute(method string, relativePath string, middlewares ...Handler) Router
	Static(relativePath string, root string)
	StaticFile(relativePath string, filepath string)
	BasePath() string
}

type TenantInfo added in v0.4.0

type TenantInfo interface {
	GetID() string
	GetName() string
}

type UserInfo added in v0.4.0

type UserInfo interface {
	GetID() string
	GetUserName() string
	GetName() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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