api

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingID         = errors.New("missing required id")
	ErrMissingField      = errors.New("missing required field")
	ErrInvalidField      = errors.New("invalid or unparsable field")
	ErrRestrictedField   = errors.New("field restricted for request")
	ErrConflictingFields = errors.New("only one field can be set")
	ErrModelIDMismatch   = errors.New("resource id does not match id of endpoint")
	ErrUnparsable        = errors.New("could not parse request")
	ErrUnknownUserRole   = errors.New("unknown user role")
	ErrWeakPassword      = errors.New("password must be at least 8 characters")
)

Functions

func NotAllowed

func NotAllowed(c *gin.Context)

NotAllowed returns a JSON 405 response for the API.

func NotFound

func NotFound(c *gin.Context)

NotFound returns a JSON 404 response for the API. NOTE: we know it's weird to put server-side handlers like NotFound and NotAllowed here in the client/api side package but it unifies where we keep our error handling mechanisms.

Types

type LoginReply

type LoginReply struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type ReauthenticateRequest

type ReauthenticateRequest struct {
	RefreshToken string `json:"refresh_token"`
}

type RegisterReply

type RegisterReply struct {
	ID    int64  `json:"user_id"`
	Name  string `json:"name"`
	Email string `json:"email"`
	Role  string `json:"role"`
}

type RegisterRequest

type RegisterRequest struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

func (*RegisterRequest) Validate

func (r *RegisterRequest) Validate() error

type Reply

type Reply struct {
	Success bool   `json:"success"`
	Error   string `json:"error,omitempty" yaml:"error,omitempty"`
}

Reply contains standard fields that are embedded in most API responses

func ErrorResponse

func ErrorResponse(err interface{}) Reply

Construct a new response for an error or simply return unsuccessful.

type StatusReply

type StatusReply struct {
	Status  string `json:"status"`
	Uptime  string `json:"uptime,omitempty"`
	Version string `json:"version,omitempty"`
}

StatusReply is returned on status requests and heartbeats

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL