Documentation ¶
Index ¶
- func ArrContains[T string | int | float32](arr []T, val T) bool
- func GenerateQueryComponenFromStruct(model interface{}, skips []string) (string, []interface{}, string)
- func GetStructKey(field reflect.StructField) string
- func GetStructValue(value reflect.Value) interface{}
- func MethodNotAllowedHandler(w http.ResponseWriter, r *http.Request)
- func PanicHandler(next http.Handler) http.Handler
- func RouteNotFoundHandler(w http.ResponseWriter, r *http.Request)
- func WriteJson(w http.ResponseWriter, data interface{})
- type API
- type Controller
- type ControllerConfig
- type ControllerImpl
- type ErrorOption
- type Handler
- type HttpError
- func BadRequest(message, code string) *HttpError
- func Forbidden(message, code string) *HttpError
- func InternalServerError(message, code string) *HttpError
- func MethodNotAllowed(message, code string) *HttpError
- func NewErr(opts ...ErrorOption) *HttpError
- func NotFound(message, code string) *HttpError
- func TooManyRequest(message, code string) *HttpError
- func Unauthorized(message, code string) *HttpError
- func UnprocessableEntity(message, code string) *HttpError
- type Map
- type Options
- type Request
- type Response
- type Route
- type RouteOption
- type StringMap
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetStructKey ¶
func GetStructKey(field reflect.StructField) string
func GetStructValue ¶
func MethodNotAllowedHandler ¶
func MethodNotAllowedHandler(w http.ResponseWriter, r *http.Request)
func RouteNotFoundHandler ¶
func RouteNotFoundHandler(w http.ResponseWriter, r *http.Request)
func WriteJson ¶
func WriteJson(w http.ResponseWriter, data interface{})
Types ¶
type API ¶
func (*API) AddController ¶
func (app *API) AddController(ctrl Controller)
type Controller ¶
type Controller interface {
GetConfig() ControllerConfig
}
type ControllerConfig ¶
type ControllerImpl ¶
type ControllerImpl struct { }
type ErrorOption ¶
type ErrorOption func(*HttpError)
func WithCode ¶
func WithCode(code string) ErrorOption
func WithData ¶
func WithData(data interface{}) ErrorOption
func WithMessage ¶
func WithMessage(message string) ErrorOption
func WithStatus ¶
func WithStatus(status int) ErrorOption
type HttpError ¶
type HttpError struct { Message string `json:"message"` Code string `json:"code"` Status int `json:"status"` Data *interface{} `json:"data,omitempty"` }
func BadRequest ¶
func InternalServerError ¶
func MethodNotAllowed ¶
func NewErr ¶
func NewErr(opts ...ErrorOption) *HttpError
func TooManyRequest ¶
func Unauthorized ¶
func UnprocessableEntity ¶
func (*HttpError) Write ¶
func (err *HttpError) Write(w http.ResponseWriter)
type Response ¶
type Response struct { Message string `json:"message"` Data interface{} `json:"data"` }
func NewResponse ¶
func NewResponse() *Response
func (*Response) SetMessage ¶
type Route ¶
type Route struct { Method string Path string Handler Handler Version int Middlewares *[]func(http.Handler) http.Handler }
func (*Route) GetVersionedPath ¶
type RouteOption ¶
type RouteOption func(*Route)
func WithMiddleware ¶
func WithMiddleware(handlers ...func(http.Handler) http.Handler) RouteOption
func WithPath ¶
func WithPath(path string) RouteOption
func WithVersion ¶
func WithVersion(version int) RouteOption
type ValidationError ¶
type ValidationError struct { Field string `json:"field"` Tag string `json:"tag"` Value string `json:"value"` }
func ValidateStruct ¶
func ValidateStruct(data interface{}) []*ValidationError
Click to show internal directories.
Click to hide internal directories.