Documentation ¶
Index ¶
- Variables
- func CreateSha1Hash(str string) string
- func ErrSuffix(in string) string
- func GetSecureString() string
- func GetTempPassword(email string, salt string) string
- func GetUUID() string
- func HashPassword(pwd string, salt string) string
- func RegisterMetadataEndpoint(s Service)
- func RegisterOpenApiEndpoint(s Service)
- func RegisterService[T IService](r IRequestContext, service T) T
- func RequestHandler[I, O any, C IRequestContext](ctx *RequestContext, in *I, handler HandleFunc[I, O, C]) O
- func ToSnakeCase(str string) string
- func VerifyPassword(pwd string) error
- type ApiDoc
- type Error
- type HandleFunc
- type IOTime
- type IRequestContext
- type IService
- type Inner
- type Mail
- type MetaArgument
- type MetaRoute
- type Model
- type Modelable
- type Option
- type Recipient
- type RequestContext
- func (r *RequestContext) AddService(svc IService)
- func (r *RequestContext) Dispose()
- func (r *RequestContext) GetAccessToken() string
- func (r *RequestContext) Init(ctx RequestContext)
- func (r *RequestContext) OnAuthentication()
- func (r *RequestContext) OnException()
- func (r *RequestContext) OnSuccess()
- func (r *RequestContext) Success() Success
- type Route
- type Service
- type Success
- type Union
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RecordNotFound = Error{Code: 1, Type: "RecordNotFound", Message: "The database record was not found"} UserNotFound = Error{Code: 10, Status: http.StatusNotFound, Type: "UserNotFound", Message: "user does not exist"} UserAlreadyExists = Error{Code: 11, Type: "UserAlreadyExists", Message: "user already exists"} UsernameAlreadyTaken = Error{Code: 12, Type: "UsernameAlreadyTaken", Message: "username already taken"} UserNotActivated = Error{Code: 100, Type: "UserNotActivated", Message: "activation required"} InvalidActivateToken = Error{Code: 101, Type: "InvalidActivateToken", Message: "invalid token"} InvalidResetToken = Error{Code: 110, Type: "InvalidResetToken", Message: "invalid token"} PasswordTooShort = Error{Code: 200, Type: "PasswordTooShort", Message: "password too short"} PasswordNeedsUpperChar = Error{Code: 201, Type: "PasswordNeedsUpperChar", Message: "password needs upper char"} PasswordNeedsLowerChar = Error{Code: 202, Type: "PasswordNeedsLowerChar", Message: "password needs lower char"} PasswordNeedsDigit = Error{Code: 203, Type: "PasswordNeedsDigit", Message: "password needs digit"} InvalidPassword = Error{Code: 220, Type: "InvalidPassword", Message: "invalid password"} InvalidEmailAddress = Error{Code: 221, Type: "InvalidEmailAddress", Message: "email address is not valid"} AccessTokenLimit = Error{Code: 230, Type: "AccessTokenLimit", Message: "device login limit exceeded"} ConsumerNotFound = Error{Code: 300, Type: "ConsumerNotFound", Message: "consumer does not exist."} NamespaceNotFound = Error{Code: 400, Type: "NamespaceNotFound", Message: "namespace does not exist."} OrganizationNotFound = Error{Code: 500, Type: "OrganizationNotFound", Message: "organization does not exist"} OrganizationAlreadyExists = Error{Code: 501, Type: "OrganizationAlreadyExists", Message: "organization already exists"} ProjectNotFound = Error{Code: 510, Type: "ProjectNotFound", Message: "project does not exist"} ProjectAlreadyExists = Error{Code: 512, Type: "ProjectAlreadyExists", Message: "project already exists"} InviteTokenNotFound = Error{Code: 600, Type: "InviteTokenNotFound", Message: "invite token does not exist"} PolicyNotFound = Error{Code: 700, Type: "PolicyNotFound", Message: "policy does not exist"} RequiresAdminPolicy = Error{Code: 700, Type: "RequiresAdminPolicy", Message: "Administrative policy does not exist"} RequestTokenNotFound = Error{Code: 0, Type: "RequestTokenNotFound", Message: "request token does not exist"} AccessTokenNotFound = Error{Code: 231, Status: http.StatusUnauthorized, Type: "AccessTokenNotFound", Message: "access token does not exist"} InputValidationError = Error{Code: 0, Status: http.StatusBadRequest, Type: "InputValidationError"} CaptchaInvalid = Error{Code: 20000, Type: "CaptchaInvalid"} AddressRequired = Error{Code: 30000, Type: "AddressRequired"} VoucherNotFound = Error{Code: 31001, Type: "VoucherNotFound"} VoucherRedeemed = Error{Code: 31002, Type: "VoucherRedeemed"} VoucherInvalidPublication = Error{Code: 31003, Type: "VoucherInvalidPublication"} SubscriptionHasAccess = Error{Code: 31004, Type: "SubscriptionHasAccess"} OfferNotGiftable = Error{Code: 31005, Type: "OfferNotGiftable"} CampaignNotFound = Error{Code: 32000, Type: "CampaignNotFound"} SubNotFound = Error{Code: 35000, Type: "SubNotFound"} TransNotFound = Error{Code: 35100, Type: "TransNotFound"} TransProcessed = Error{Code: 35110, Type: "TransProcessed"} PaymentAlreadyCaptured = Error{Code: 35200, Type: "PaymentAlreadyCaptured"} PaymentMethodUnsupported = Error{Code: 36200, Type: "PaymentMethodUnsupported"} AlreadySubscribedToPackage = Error{Code: 35001, Type: "AlreadySubscribedToPackage"} )
View Source
var Config struct { // Enables verbose logging Debug bool TestMode bool AuthCookieName string }
Functions ¶
func CreateSha1Hash ¶
func GetSecureString ¶
func GetSecureString() string
Generates a SHA512 hash from a UUID. This string can be used as a token for authentication, etc.
func GetTempPassword ¶
func HashPassword ¶
func RegisterMetadataEndpoint ¶
func RegisterMetadataEndpoint(s Service)
func RegisterOpenApiEndpoint ¶
func RegisterOpenApiEndpoint(s Service)
func RegisterService ¶
func RegisterService[T IService](r IRequestContext, service T) T
Register services or middlware for lifetime events
func RequestHandler ¶
func RequestHandler[I, O any, C IRequestContext](ctx *RequestContext, in *I, handler HandleFunc[I, O, C]) O
func ToSnakeCase ¶
func VerifyPassword ¶
Types ¶
type ApiDoc ¶
type ApiDoc struct { Service Service // contains filtered or unexported fields }
func NewApiDocumentation ¶
type Error ¶
type HandleFunc ¶
type HandleFunc[I, O any, C IRequestContext] func(context C, in *I) O
func Base ¶
func Base[I, O any, C IRequestContext](r Route, handler HandleFunc[I, O, C]) HandleFunc[I, O, C]
Binds a route to a handler function
type IRequestContext ¶
type IRequestContext interface { Init(r RequestContext) AddService(svc IService) OnAuthentication() OnException() OnSuccess() Dispose() }
type Mail ¶
type MetaArgument ¶
type Option ¶
func (Option[T]) AlternateType ¶
TODO: rename to GetUnderlyingType/GetAPIType or something
func (Option[T]) MarshalJSON ¶
func (*Option[T]) Or ¶
func (d *Option[T]) Or(v T) T
Return current value if set, or else return specified value.
func (*Option[T]) UnmarshalJSON ¶
type RequestContext ¶
type RequestContext struct { Route *Route Service Service Request *http.Request Writer http.ResponseWriter AccessToken string // contains filtered or unexported fields }
func (*RequestContext) AddService ¶
func (r *RequestContext) AddService(svc IService)
func (*RequestContext) Dispose ¶
func (r *RequestContext) Dispose()
func (*RequestContext) GetAccessToken ¶
func (r *RequestContext) GetAccessToken() string
func (*RequestContext) Init ¶
func (r *RequestContext) Init(ctx RequestContext)
func (*RequestContext) OnAuthentication ¶
func (r *RequestContext) OnAuthentication()
func (*RequestContext) OnException ¶
func (r *RequestContext) OnException()
func (*RequestContext) OnSuccess ¶
func (r *RequestContext) OnSuccess()
func (*RequestContext) Success ¶
func (r *RequestContext) Success() Success
type Route ¶
type Route struct { Path string Description string Permission string Category string Service Service // TODO: fill this Summary string OpId string // The operation ID of the endpoint ServicePath string FilePath string Errors []Error // Errors returned by route Input any Output any InputSchema string Handle func(r *RequestContext, in any) any }
type Service ¶
type Service struct { Name string Version string Prefix string Path string SnakifyIO bool Overview []byte StaticFiles *embed.FS }
func (Service) ContainsRoute ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.