Documentation ¶
Index ¶
- Constants
- func CustomTagNameFunc() validator.TagNameFunc
- func MockSuccessDataHandler(msg string, data any) gin.HandlerFunc
- func MockSuccessMsgHandler(msg string) gin.HandlerFunc
- func MockTestAuthenticationProvider(t *testing.T, auth AuthenticationProvider, handler gin.HandlerFunc, ...) *httptest.ResponseRecorder
- func MockTestAuthorizationProvider(t *testing.T, role string, auth AuthenticationProvider, ...) *httptest.ResponseRecorder
- func MockTestController(t *testing.T, httpMethod, url, body string, controller Controller) *httptest.ResponseRecorder
- func MockTestHandler(t *testing.T, httpMethod, path, url, body string, handler gin.HandlerFunc, ...) *httptest.ResponseRecorder
- func MockTestRootMiddleware(t *testing.T, middleware RootMiddleware, handler gin.HandlerFunc, ...) *httptest.ResponseRecorder
- func MockTestRootMiddlewareWithUrl(t *testing.T, path, url string, middleware RootMiddleware, ...) *httptest.ResponseRecorder
- func ReqBody[T any](ctx *gin.Context, dto Dto[T]) (*T, error)
- func ReqHeaders[T any](ctx *gin.Context, dto Dto[T]) (*T, error)
- func ReqParams[T any](ctx *gin.Context, dto Dto[T]) (*T, error)
- func ReqQuery[T any](ctx *gin.Context, dto Dto[T]) (*T, error)
- type ApiError
- func NewBadRequestError(message string, err error) ApiError
- func NewForbiddenError(message string, err error) ApiError
- func NewInternalServerError(message string, err error) ApiError
- func NewNotFoundError(message string, err error) ApiError
- func NewUnauthorizedError(message string, err error) ApiError
- type AuthenticationProvider
- type AuthorizationProvider
- type BaseController
- type BaseMiddleware
- type BaseMiddlewareProvider
- type BaseModule
- type BaseRouter
- type BaseService
- type Controller
- type Dto
- type MockAuthenticationProvider
- type MockAuthorizationProvider
- type MockDto
- type Module
- type Param0MiddlewareProvider
- type Param1MiddlewareProvider
- type Param2MiddlewareProvider
- type Param3MiddlewareProvider
- type ParamNMiddlewareProvider
- type ResCode
- type Response
- func NewBadRequestResponse(message string) Response
- func NewForbiddenResponse(message string) Response
- func NewInternalServerErrorResponse(message string) Response
- func NewNotFoundResponse(message string) Response
- func NewSuccessDataResponse(message string, data any) Response
- func NewSuccessMsgResponse(message string) Response
- func NewUnauthorizedResponse(message string) Response
- type ResponseSender
- type RootMiddleware
- type Router
- type SendResponse
Constants ¶
View Source
const ( ApiKeyHeader = "x-api-key" AuthorizationHeader = "Authorization" )
Variables ¶
This section is empty.
Functions ¶
func CustomTagNameFunc ¶
func CustomTagNameFunc() validator.TagNameFunc
func MockSuccessDataHandler ¶
func MockSuccessDataHandler(msg string, data any) gin.HandlerFunc
func MockSuccessMsgHandler ¶
func MockSuccessMsgHandler(msg string) gin.HandlerFunc
func MockTestAuthenticationProvider ¶
func MockTestAuthenticationProvider( t *testing.T, auth AuthenticationProvider, handler gin.HandlerFunc, headers ...primitive.E, ) *httptest.ResponseRecorder
func MockTestAuthorizationProvider ¶
func MockTestAuthorizationProvider( t *testing.T, role string, auth AuthenticationProvider, authz AuthorizationProvider, handler gin.HandlerFunc, headers ...primitive.E, ) *httptest.ResponseRecorder
func MockTestController ¶
func MockTestController( t *testing.T, httpMethod, url, body string, controller Controller, ) *httptest.ResponseRecorder
func MockTestHandler ¶
func MockTestHandler( t *testing.T, httpMethod, path, url, body string, handler gin.HandlerFunc, headers ...primitive.E, ) *httptest.ResponseRecorder
func MockTestRootMiddleware ¶
func MockTestRootMiddleware( t *testing.T, middleware RootMiddleware, handler gin.HandlerFunc, headers ...primitive.E, ) *httptest.ResponseRecorder
func MockTestRootMiddlewareWithUrl ¶
func MockTestRootMiddlewareWithUrl( t *testing.T, path, url string, middleware RootMiddleware, handler gin.HandlerFunc, headers ...primitive.E, ) *httptest.ResponseRecorder
Types ¶
type ApiError ¶
func NewBadRequestError ¶
func NewForbiddenError ¶
func NewInternalServerError ¶
func NewNotFoundError ¶
func NewUnauthorizedError ¶
type AuthenticationProvider ¶
type AuthenticationProvider Param0MiddlewareProvider
type AuthorizationProvider ¶
type AuthorizationProvider ParamNMiddlewareProvider[string]
type BaseController ¶
type BaseController interface { ResponseSender Path() string Authentication() gin.HandlerFunc Authorization(role string) gin.HandlerFunc }
func NewBaseController ¶
func NewBaseController(basePath string, authProvider AuthenticationProvider, authorizeProvider AuthorizationProvider) BaseController
type BaseMiddleware ¶
type BaseMiddleware interface { ResponseSender Debug() bool }
func NewBaseMiddleware ¶
func NewBaseMiddleware() BaseMiddleware
type BaseMiddlewareProvider ¶
type BaseMiddlewareProvider interface { BaseMiddleware }
type BaseModule ¶ added in v1.1.2
type BaseModule[T any] interface { GetInstance() *T RootMiddlewares() []RootMiddleware AuthenticationProvider() AuthenticationProvider AuthorizationProvider() AuthorizationProvider }
type BaseRouter ¶ added in v1.1.0
type BaseRouter interface { GetEngine() *gin.Engine RegisterValidationParsers(tagNameFunc validator.TagNameFunc) LoadRootMiddlewares(middlewares []RootMiddleware) Start(ip string, port uint16) }
type BaseService ¶
func NewBaseService ¶
func NewBaseService() BaseService
type Controller ¶
type Controller interface { BaseController MountRoutes(group *gin.RouterGroup) }
type MockAuthenticationProvider ¶
func (*MockAuthenticationProvider) Debug ¶
func (m *MockAuthenticationProvider) Debug() bool
func (*MockAuthenticationProvider) Middleware ¶
func (m *MockAuthenticationProvider) Middleware() gin.HandlerFunc
func (*MockAuthenticationProvider) Send ¶
func (m *MockAuthenticationProvider) Send(ctx *gin.Context) SendResponse
type MockAuthorizationProvider ¶
func (*MockAuthorizationProvider) Debug ¶
func (m *MockAuthorizationProvider) Debug() bool
func (*MockAuthorizationProvider) Middleware ¶
func (m *MockAuthorizationProvider) Middleware(params ...string) gin.HandlerFunc
func (*MockAuthorizationProvider) Send ¶
func (m *MockAuthorizationProvider) Send(ctx *gin.Context) SendResponse
type MockDto ¶
type MockDto struct {
Field string `json:"field" form:"field" uri:"field" binding:"required" validate:"required"`
}
func (*MockDto) ValidateErrors ¶
type Module ¶
type Module[T any] interface { BaseModule[T] Controllers() []Controller }
type Param0MiddlewareProvider ¶
type Param0MiddlewareProvider interface { BaseMiddlewareProvider Middleware() gin.HandlerFunc }
type Param1MiddlewareProvider ¶
type Param1MiddlewareProvider[T any] interface { BaseMiddlewareProvider Middleware(param1 T) gin.HandlerFunc }
type Param2MiddlewareProvider ¶
type Param2MiddlewareProvider[T any, V any] interface { BaseMiddlewareProvider Middleware(param1 T, param2 V) gin.HandlerFunc }
type Param3MiddlewareProvider ¶
type Param3MiddlewareProvider[T any, V any, W any] interface { BaseMiddlewareProvider Middleware(param1 T, param2 V, param3 W) gin.HandlerFunc }
type ParamNMiddlewareProvider ¶
type ParamNMiddlewareProvider[T any] interface { BaseMiddlewareProvider Middleware(params ...T) gin.HandlerFunc }
type Response ¶
func NewBadRequestResponse ¶
func NewForbiddenResponse ¶
func NewNotFoundResponse ¶
func NewSuccessDataResponse ¶
func NewSuccessMsgResponse ¶
func NewUnauthorizedResponse ¶
type ResponseSender ¶
type ResponseSender interface { Debug() bool Send(ctx *gin.Context) SendResponse }
func NewResponseSender ¶
func NewResponseSender() ResponseSender
type RootMiddleware ¶
type RootMiddleware interface { BaseMiddleware Attach(engine *gin.Engine) Handler(ctx *gin.Context) }
type Router ¶
type Router interface { BaseRouter LoadControllers(controllers []Controller) }
type SendResponse ¶
type SendResponse interface { SuccessMsgResponse(message string) SuccessDataResponse(message string, data any) BadRequestError(message string, err error) ForbiddenError(message string, err error) NotFoundError(message string, err error) InternalServerError(message string, err error) MixedError(err error) }
Click to show internal directories.
Click to hide internal directories.