Documentation
¶
Overview ¶
Package api contains commonly used constants and functions for the HTTP API.
Index ¶
- Constants
- func EncodeError(_ context.Context, err error, w http.ResponseWriter)
- func EncodeResponse(_ context.Context, w http.ResponseWriter, response any) error
- func RequestIDMiddleware(idp supermq.IDProvider) func(http.Handler) http.Handler
- func ValidateEmail(email string) (err error)
- func ValidateName(id string) error
- func ValidateRoute(route string) error
- func ValidateUUID(extID string) (err error)
- func ValidateUserName(name string) error
Constants ¶
View Source
const ( OffsetKey = "offset" DirKey = "dir" OrderKey = "order" LimitKey = "limit" OnlyTotal = "only_total" NameOrder = "name" IDOrder = "id" AscDir = "asc" DescDir = "desc" UpdatedAtOrder = "updated_at" CreatedAtOrder = "created_at" MetadataKey = "metadata" NameKey = "name" TagKey = "tag" StatusKey = "status" ClientKey = "client" ChannelKey = "channel" ConnTypeKey = "connection_type" GroupKey = "group" DomainKey = "domain" StartLevelKey = "start_level" EndLevelKey = "end_level" TreeKey = "tree" ParentKey = "parent_id" LevelKey = "level" RootGroupKey = "root_group" TokenKey = "token" SubjectKey = "subject" ObjectKey = "object" RolesKey = "roles" ActionKey = "action" ActionsKey = "actions" RoleIDKey = "role_id" RoleNameKey = "role_name" AccessProviderIDKey = "access_provider_id" AccessTypeKey = "access_type" UsernameKey = "username" UserKey = "user" EmailKey = "email" FirstNameKey = "first_name" LastNameKey = "last_name" DefTotal = uint64(100) DefOffset = 0 DefOrder = "updated_at" DefDir = "desc" DefLimit = 10 DefLevel = 0 DefStartLevel = 1 DefEndLevel = 0 DefStatus = "enabled" DefClientStatus = clients.Enabled DefUserStatus = users.Enabled DefGroupStatus = groups.Enabled // ContentType represents JSON content type. ContentType = "application/json" // MaxNameSize limits name size to prevent making them too complex. MaxLimitSize = 100 MaxNameSize = 1024 MaxIDSize = 36 )
Variables ¶
This section is empty.
Functions ¶
func EncodeError ¶
func EncodeError(_ context.Context, err error, w http.ResponseWriter)
EncodeError encodes an error response.
func EncodeResponse ¶
EncodeResponse encodes successful response.
func RequestIDMiddleware ¶
func ValidateEmail ¶ added in v0.18.1
func ValidateUserName ¶
ValidateUserName validates user name format.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.