Documentation ¶
Index ¶
- Variables
- func EndpointToHandleFunc(endpoint Endpoint) echo.HandlerFunc
- func GetUrlParam[T any](ctx *Context, key string) T
- func NewLogger(ctx context.Context) *logrus.Entry
- func SetLogFormat(fm *nested.Formatter)
- func ToHandleFunc(fn Endpoint) echo.HandlerFunc
- type Config
- type Context
- func (c *Context) GetConfig() (Config, error)
- func (c *Context) NoContent()
- func (c *Context) Ok()
- func (c *Context) ParseFormBody(target any) error
- func (c *Context) ParseJsonBody(target any) error
- func (c *Context) SendStatus(httpstatus int)
- func (c *Context) StatusWithBody(httpstatus int, response any)
- func (c *Context) Stop()
- func (c *Context) WriteJson(response any)
- type Controller
- type Endpoint
- type Handler
- type Logger
- type OnError
Constants ¶
This section is empty.
Variables ¶
var ( ErrConfigNotFound = errors.New("config not found") ErrorConfigTypeNotMatch = errors.New("config type not match") )
Functions ¶
func EndpointToHandleFunc ¶
func EndpointToHandleFunc(endpoint Endpoint) echo.HandlerFunc
EndpointToHandleFunc converts an Endpoint to an echo.HandlerFunc
func GetUrlParam ¶
GetUrlParam returns the value of the url param with the given key.
func SetLogFormat ¶
SetLogFormat sets the log format This function must be called before the first call to NewLogger
func ToHandleFunc ¶
func ToHandleFunc(fn Endpoint) echo.HandlerFunc
ToHandleFunc converts an Endpoint to an echo.HandlerFunc
Types ¶
type Config ¶
type Config interface { GetPort() int GetTimeout() time.Duration GetRootPath() string GetProperty(string) any }
Config is the configuration of the application.
type Context ¶
type Context struct { echo.Context Log Logger // contains filtered or unexported fields }
Context is a wrapper for echo.Context
func NewContext ¶
func (*Context) ParseFormBody ¶
ParseFormBody parse the form body and set the values to the target and the target must be a pointer to a struct. The struct fields must have the tag "form" with the name of the form field or the name of the struct field in lowercase. Example:
type User struct { Name string `form:"name"` Age int `form:"age"` } var user User err := c.ParseFormBody(&user) if err != nil { // handle error }
func (*Context) ParseJsonBody ¶
ParseJsonBody parse the json body and set the values to the target and the target must be a pointer to a struct. The struct fields must have the tag "json" with the name of the json field or the name of the struct field in lowercase. Example:
type User struct { Name string `json:"name"` Age int `json:"age"` } var user User err := c.ParseJsonBody(&user) if err != nil { // handle error }
func (*Context) SendStatus ¶
SendStatus send a status code with a default status message
func (*Context) StatusWithBody ¶
StatusWithBody send a status code with a body
type Controller ¶
Controller is a struct that contains a group of endpoints and a path to be used in the server
func (*Controller) Build ¶
func (c *Controller) Build(e *echo.Echo)
Build is a method that will build all endpoints and add them to the server
type Endpoint ¶
type Endpoint struct { Path string Method string Middlewares []echo.MiddlewareFunc Handler Handler }
Endpoint is a struct that contains a path, a method, a handler and a list of middlewares that will be used in the server