ginx

package
v0.0.0-...-ef818a3 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORS

func CORS(c *gin.Context)

func GinHandler

func GinHandler(f any) gin.HandlerFunc

func GinMiddleware

func GinMiddleware(f any) gin.HandlerFunc

func WithCustomEngine

func WithCustomEngine(e *gin.Engine) func(*Module)

func WithFileName

func WithFileName(name string) func(*File)

func WithMimeType

func WithMimeType(mimeType string) func(*File)

func WithPrefix

func WithPrefix(prefix string) func(*Module)

Types

type File

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

func NewFile

func NewFile(content []byte, opts ...func(*File)) *File

func (*File) Content

func (f *File) Content() []byte

func (*File) MimeType

func (f *File) MimeType() string

func (*File) Name

func (f *File) Name() string

type Filters

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

func NewFiltersFromCtx

func NewFiltersFromCtx(ctx *gin.Context) *Filters

func (Filters) ParseAll

func (f Filters) ParseAll() (results []any)

type IFile

type IFile interface {
	Name() string
	MimeType() string
	Content() []byte
}

type IMeta

type IMeta interface {
	GetMeta() map[string]any
}

type IResponse

type IResponse[CTX any] interface {
	SetData(any) IResponse[CTX]
	SetMeta(IMeta) IResponse[CTX]
	SetError(error) IResponse[CTX]
	SetFile(IFile) IResponse[CTX]
	Do(CTX)
}

func NewRestfulResponse

func NewRestfulResponse() IResponse[*gin.Context]

type JwtAuthMiddlewareBuilder

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

func NewJwtAuthMiddlewareBuilder

func NewJwtAuthMiddlewareBuilder() *JwtAuthMiddlewareBuilder

func (*JwtAuthMiddlewareBuilder) Build

func (j *JwtAuthMiddlewareBuilder) Build() func(*gin.Context) error

func (*JwtAuthMiddlewareBuilder) SetHeader

func (*JwtAuthMiddlewareBuilder) SetQuery

func (j *JwtAuthMiddlewareBuilder) SetQuery(queryField string) *JwtAuthMiddlewareBuilder

func (*JwtAuthMiddlewareBuilder) SetSalt

func (*JwtAuthMiddlewareBuilder) SetUserIdentifier

func (j *JwtAuthMiddlewareBuilder) SetUserIdentifier(f func(claims jwt2.MapClaims) error) *JwtAuthMiddlewareBuilder

type Meta

type Meta struct {
	Code        int
	CurrentPage uint
	Total       uint
	LastPage    uint
	PerPage     uint
}

func (*Meta) GetMeta

func (m *Meta) GetMeta() (result map[string]any)

type Module

type Module struct {
	app.IsModule
	// contains filtered or unexported fields
}

func NewModule

func NewModule(opts ...func(*Module)) *Module

func (*Module) Any

func (m *Module) Any(route string, handler any, middlewares ...any) Router

func (*Module) DELETE

func (m *Module) DELETE(route string, handler any, middlewares ...any) Router

func (*Module) GET

func (m *Module) GET(route string, handler any, middlewares ...any) Router

func (*Module) Group

func (m *Module) Group(prefix string, middlewares ...any) Router

func (*Module) HEAD

func (m *Module) HEAD(route string, handler any, middlewares ...any) Router

func (*Module) Init

func (m *Module) Init() (err error)

func (*Module) OPTIONS

func (m *Module) OPTIONS(route string, handler any, middlewares ...any) Router

func (*Module) PATCH

func (m *Module) PATCH(route string, handler any, middlewares ...any) Router

func (*Module) POST

func (m *Module) POST(route string, handler any, middlewares ...any) Router

func (*Module) PUT

func (m *Module) PUT(route string, handler any, middlewares ...any) Router

func (*Module) Start

func (m *Module) Start()

func (*Module) Stop

func (m *Module) Stop()

type NewResponseFunc

type NewResponseFunc func() IResponse[*gin.Context]

type Page

type Page struct {
	Page int `form:"page"`
	Size int `form:"size"`
}

func NewPageFromCtx

func NewPageFromCtx(ctx *gin.Context, defaultSize int) *Page

func (Page) Apply

func (p Page) Apply(db *gorm.DB) (newDB *gorm.DB, err error)

func (Page) Offset

func (p Page) Offset() int

type RestfulResponse

type RestfulResponse struct {
	Data    any            `json:"data"`
	Message string         `json:"message"`
	Meta    map[string]any `json:"meta,omitempty"`
	// contains filtered or unexported fields
}

func (*RestfulResponse) Do

func (r *RestfulResponse) Do(ctx *gin.Context)

func (*RestfulResponse) SetData

func (r *RestfulResponse) SetData(data any) IResponse[*gin.Context]

func (*RestfulResponse) SetError

func (r *RestfulResponse) SetError(err error) IResponse[*gin.Context]

func (*RestfulResponse) SetFile

func (r *RestfulResponse) SetFile(file IFile) IResponse[*gin.Context]

func (*RestfulResponse) SetMeta

func (r *RestfulResponse) SetMeta(meta IMeta) IResponse[*gin.Context]

type Router

type Router interface {
	Any(route string, handler any, middlewares ...any) Router
	GET(route string, handler any, middlewares ...any) Router
	POST(route string, handler any, middlewares ...any) Router
	DELETE(route string, handler any, middlewares ...any) Router
	PATCH(route string, handler any, middlewares ...any) Router
	PUT(route string, handler any, middlewares ...any) Router
	OPTIONS(route string, handler any, middlewares ...any) Router
	HEAD(route string, handler any, middlewares ...any) Router
	Group(prefix string, middlewares ...any) Router
}

type Sorts

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

func NewSortsFromCtx

func NewSortsFromCtx(ctx *gin.Context) *Sorts

func (Sorts) Apply

func (s Sorts) Apply(db *gorm.DB) (newDB *gorm.DB, err error)

Jump to

Keyboard shortcuts

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