Documentation
¶
Index ¶
- func CompileValidationErrors(payload any) map[string]string
- func SetupState(s UAPIState)
- type APIRouter
- type AuthData
- type AuthType
- type HttpResponse
- func DefaultResponse(statusCode int) HttpResponse
- func MarshalReq(r *http.Request, dst any) (resp HttpResponse, ok bool)
- func MarshalReqWithHeaders(r *http.Request, dst any, headers map[string]string) (resp HttpResponse, ok bool)
- func ValidatorErrorResponse(compiled map[string]string, v validator.ValidationErrors) HttpResponse
- type Method
- type Route
- type RouteData
- type Router
- type UAPIConstants
- type UAPIDefaultResponder
- type UAPIInitData
- type UAPIState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileValidationErrors ¶
func SetupState ¶
func SetupState(s UAPIState)
Types ¶
type HttpResponse ¶
type HttpResponse struct {
Data string
Bytes []byte
Json any
Headers map[string]string
Status int
Redirect string
}
func DefaultResponse ¶
func DefaultResponse(statusCode int) HttpResponse
func MarshalReq ¶
func MarshalReq(r *http.Request, dst any) (resp HttpResponse, ok bool)
func MarshalReqWithHeaders ¶
func ValidatorErrorResponse ¶
func ValidatorErrorResponse(compiled map[string]string, v validator.ValidationErrors) HttpResponse
type Route ¶
type Router ¶
type Router interface {
Get(pattern string, h http.HandlerFunc)
Post(pattern string, h http.HandlerFunc)
Patch(pattern string, h http.HandlerFunc)
Put(pattern string, h http.HandlerFunc)
Delete(pattern string, h http.HandlerFunc)
Head(pattern string, h http.HandlerFunc)
}
type UAPIConstants ¶
type UAPIDefaultResponder ¶
type UAPIInitData ¶
type UAPIInitData struct {
Tag string
}
type UAPIState ¶
type UAPIState struct {
Logger *zap.Logger
Authorize func(r Route, req *http.Request) (AuthData, HttpResponse, bool)
AuthTypeMap map[string]string
RouteDataMiddleware func(rd *RouteData, req *http.Request) (*RouteData, error)
BaseSanityCheck func(r Route) error
PatchDocs func(d *docs.Doc) *docs.Doc
Context context.Context
Constants *UAPIConstants
DefaultResponder UAPIDefaultResponder
InitData UAPIInitData
}
var (
State *UAPIState
)
func (*UAPIState) SetCurrentTag ¶
Click to show internal directories.
Click to hide internal directories.