Documentation
¶
Index ¶
- Variables
- func FormBool(value url.Values, key string) bool
- func GetBool(value url.Values, key string) app.Nullable[bool]
- func GetBoolDefault(value url.Values, key string, defaultValue bool) bool
- func GetID(ctx context.Context) string
- func GetIP(r *http.Request) net.IP
- func GetInt32FromQuery(values url.Values, key string) app.Int32
- func GetInt32RangeFromQuery(query url.Values, queryParam string) app.Int32Range
- func GetInt64Array(value url.Values, key string) []int64
- func GetPage(values url.Values, key string) uint32
- func GetPageSize(values url.Values, key string, minValue, maxValue, defaultValue uint32) uint32
- func GetRequest(ctx context.Context) *http.Request
- func GetStringArray(value url.Values, key string) []string
- func GetUUIDArray(value url.Values, key string) []uuid.UUID
- func IsSameURL(url *url.URL, str string) bool
- func MakeRecoveryMiddleware() func(next http.Handler) http.Handler
- func ParseInt64Array(value string) []int64
- func ParseInt64Slug(slug string) (int64, string)
- func ParseStringArray(value string) []string
- func PreferredMimeTypeIsJSON(r *http.Request) bool
- func ReadJSONBody(r *http.Request, v any) error
- func ReqCtxMiddleware(next http.Handler) http.Handler
- func SplitByWithEscape(s string, c byte) []string
- func URLParamInt64(r *http.Request, name string) (int64, error)
- func URLParamUUID(r *http.Request, name string) (uuid.UUID, error)
- func URLQueryParamInt64(r *http.Request, name string) (int64, error)
- func URLQueryParamUUID(r *http.Request, name string) (uuid.UUID, error)
- func Write500(w http.ResponseWriter, r *http.Request, err error)
- func WriteCustomErrorPage(w http.ResponseWriter, r *http.Request, title, subtitle string, err error)
- func WriteTemplate(w http.ResponseWriter, ctx context.Context, t templ.Component)
- type APIBody
- type APIResponse
- type Notification
- type NotificationType
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrJSONDecodeEOF = errTypeJSONDecode.New("EOF - http body appears to be empty")
)
Functions ¶
func GetInt32RangeFromQuery ¶
func GetInt32RangeFromQuery(query url.Values, queryParam string) app.Int32Range
func GetPageSize ¶
func ParseInt64Array ¶
func ParseInt64Slug ¶
func ParseStringArray ¶
func PreferredMimeTypeIsJSON ¶
PreferredMimeTypeIsJSON checks if the client prefers JSON mime types more than other types
func SplitByWithEscape ¶
func WriteCustomErrorPage ¶
func WriteTemplate ¶
Types ¶
type APIBody ¶
type APIBody interface {
WriteHttpBody(w http.ResponseWriter)
}
type APIResponse ¶
type APIResponse struct {
// contains filtered or unexported fields
}
func NewAPIError ¶
func NewAPIError(err error) *APIResponse
func NewAPIErrorWithMessage ¶
func NewAPIErrorWithMessage(message string) *APIResponse
func NewAPIResponse ¶
func NewAPIResponse(data any) *APIResponse
func NewAPIResponseOK ¶
func NewAPIResponseOK() *APIResponse
func (*APIResponse) AddNotification ¶
func (r *APIResponse) AddNotification(notif Notification)
func (*APIResponse) Write ¶
func (r *APIResponse) Write(w http.ResponseWriter)
type Notification ¶
type Notification struct {
Text string `json:"text"`
Type NotificationType `json:"type"`
}
func NewNotification ¶
func NewNotification(text string, typ NotificationType) Notification
type NotificationType ¶
type NotificationType uint8
const ( NotificationInfo NotificationType = iota NotificationWarn NotificationError )
func (NotificationType) MarshalJSON ¶
func (n NotificationType) MarshalJSON() ([]byte, error)
Click to show internal directories.
Click to hide internal directories.