Documentation
¶
Overview ¶
Copyright 2025 M Reyhan Fahlevi Licensed under the MIT License. See LICENSE for details.
Copyright 2025 M Reyhan Fahlevi Licensed under the MIT License. See LICENSE for details.
Copyright 2025 M Reyhan Fahlevi Licensed under the MIT License. See LICENSE for details.
Copyright 2025 M Reyhan Fahlevi Licensed under the MIT License. See LICENSE for details.
Copyright 2025 M Reyhan Fahlevi Licensed under the MIT License. See LICENSE for details.
Copyright 2025 M Reyhan Fahlevi Licensed under the MIT License. See LICENSE for details.
Index ¶
- func Created(w http.ResponseWriter, data interface{}) error
- func Handle[Req any, Res any](fn HandlerFunc[Req, Res]) gin.HandlerFunc
- func JSON(w http.ResponseWriter, status int, data interface{}) error
- func Middleware[Req any](fn MiddlewareFunc[Req]) gin.HandlerFunc
- func NoContent(w http.ResponseWriter) error
- func RegisterTranslation(lang, tag, message string)
- func Success(w http.ResponseWriter, data interface{}) error
- type App
- func (a *App) DELETE(path string, handlers ...gin.HandlerFunc)
- func (a *App) EnableSwaggerUI(path string)
- func (a *App) GET(path string, handlers ...gin.HandlerFunc)
- func (a *App) Group(path string, middleware ...gin.HandlerFunc) *gin.RouterGroup
- func (a *App) PATCH(path string, handlers ...gin.HandlerFunc)
- func (a *App) POST(path string, handlers ...gin.HandlerFunc)
- func (a *App) PUT(path string, handlers ...gin.HandlerFunc)
- func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *App) Start(addr string) error
- func (a *App) Use(middleware ...gin.HandlerFunc)
- func (a *App) WithSwagger(title, version string, opts ...SwaggerOption) *App
- type Components
- type Context
- type HTTPError
- type HandlerFunc
- type MediaType
- type MiddlewareFunc
- type OpenAPIInfo
- type OpenAPISpec
- type Operation
- type Parameter
- type PathItem
- type RequestBody
- type Response
- type Schema
- type SwaggerGenerator
- func (sg *SwaggerGenerator) AddEndpoint(method, path string, requestTypes []reflect.Type, responseType reflect.Type, ...)
- func (sg *SwaggerGenerator) Generate(handlers map[string]handlerInfo) map[string]interface{}
- func (sg *SwaggerGenerator) GetJSON() ([]byte, error)
- func (sg *SwaggerGenerator) GetSpec() OpenAPISpec
- func (sg *SwaggerGenerator) UIHandler() gin.HandlerFunc
- type SwaggerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Created ¶
func Created(w http.ResponseWriter, data interface{}) error
func Handle ¶
func Handle[Req any, Res any](fn HandlerFunc[Req, Res]) gin.HandlerFunc
Handle creates a type-safe handler using gin's native functionality with automatic content-type detection
func Middleware ¶ added in v0.2.0
func Middleware[Req any](fn MiddlewareFunc[Req]) gin.HandlerFunc
Middleware creates a type-safe middleware using gin's native functionality with automatic content-type detection
func NoContent ¶
func NoContent(w http.ResponseWriter) error
func RegisterTranslation ¶ added in v0.2.0
func RegisterTranslation(lang, tag, message string)
RegisterTranslation registers a translated message for a validation tag. Example: fluxo.RegisterTranslation("jp", "required", "%s は必須です")
func Success ¶
func Success(w http.ResponseWriter, data interface{}) error
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func (*App) DELETE ¶
func (a *App) DELETE(path string, handlers ...gin.HandlerFunc)
DELETE registers a DELETE handler
func (*App) EnableSwaggerUI ¶
EnableSwaggerUI serves the Swagger UI at the specified path
func (*App) Group ¶
func (a *App) Group(path string, middleware ...gin.HandlerFunc) *gin.RouterGroup
Group creates a route group with optional middleware
func (*App) PATCH ¶
func (a *App) PATCH(path string, handlers ...gin.HandlerFunc)
PATCH registers a PATCH handler
func (*App) POST ¶
func (a *App) POST(path string, handlers ...gin.HandlerFunc)
POST registers a POST handler
func (*App) PUT ¶
func (a *App) PUT(path string, handlers ...gin.HandlerFunc)
PUT registers a PUT handler
func (*App) Use ¶
func (a *App) Use(middleware ...gin.HandlerFunc)
Use adds middleware to the gin router
func (*App) WithSwagger ¶
func (a *App) WithSwagger(title, version string, opts ...SwaggerOption) *App
WithSwagger enables swagger documentation generation and serves it at /docs
type Components ¶
type Context ¶ added in v0.2.0
func (*Context) GetAuthenticatedUser ¶ added in v0.2.0
func (*Context) SetAuthenticatedUser ¶ added in v0.2.0
type HTTPError ¶
func BadRequest ¶
func InternalServerError ¶
func NewHTTPError ¶
func Unauthorized ¶
type MiddlewareFunc ¶ added in v0.2.0
type OpenAPIInfo ¶
type OpenAPISpec ¶
type OpenAPISpec struct {
OpenAPI string `json:"openapi"`
Info OpenAPIInfo `json:"info"`
Paths map[string]PathItem `json:"paths"`
Components Components `json:"components"`
}
type RequestBody ¶
type Schema ¶
type Schema struct {
Type string `json:"type,omitempty"`
Properties map[string]Schema `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
Items *Schema `json:"items,omitempty"`
Format string `json:"format,omitempty"`
Description string `json:"description,omitempty"`
Example interface{} `json:"example,omitempty"`
}
type SwaggerGenerator ¶
type SwaggerGenerator struct {
// contains filtered or unexported fields
}
func NewSwaggerGenerator ¶
func NewSwaggerGenerator(title, version string, opts ...SwaggerOption) *SwaggerGenerator
func (*SwaggerGenerator) AddEndpoint ¶
func (*SwaggerGenerator) Generate ¶
func (sg *SwaggerGenerator) Generate(handlers map[string]handlerInfo) map[string]interface{}
Generate returns the OpenAPI spec as a map (for JSON serialization)
func (*SwaggerGenerator) GetJSON ¶
func (sg *SwaggerGenerator) GetJSON() ([]byte, error)
func (*SwaggerGenerator) GetSpec ¶
func (sg *SwaggerGenerator) GetSpec() OpenAPISpec
func (*SwaggerGenerator) UIHandler ¶
func (sg *SwaggerGenerator) UIHandler() gin.HandlerFunc
serveSwaggerUI serves the Swagger UI using gin
type SwaggerOption ¶
type SwaggerOption func(*SwaggerGenerator)
func WithSwaggerDescription ¶
func WithSwaggerDescription(desc string) SwaggerOption
func WithSwaggerPageTitle ¶
func WithSwaggerPageTitle(title string) SwaggerOption
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
auth_header
command
|
|
|
basic
command
|
|
|
db_gorm
command
|
|
|
middleware
command
|
|
|
todo_api
command
|