routes

package
v0.4.42 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextKeyOwnerID is the id that's given in jwt's iss field
	ContextKeyOwnerID contextKey = iota
	ContextKeyClient
	ContextKeyScope
	ContextKeyIat
	ContextKeyExp
	ContextKeyTokenHours
)

Variables

This section is empty.

Functions

func AddRESTRoutes

func AddRESTRoutes(r *gin.Engine)

AddRESTRoutes adds all routes

func BasicToken added in v0.1.34

func BasicToken(r *http.Request) (token string, ok bool)

BasicToken()

func BearerAuthMiddleware

func BearerAuthMiddleware() gin.HandlerFunc

BearerAuthMiddleware make sure the Bearer token exits and validate it And also get the user ID into the context

func BearerToken added in v0.1.34

func BearerToken(r *http.Request) (token string, ok bool)

BearerToken returns bearer token

func ClientAuthMiddleware

func ClientAuthMiddleware() gin.HandlerFunc

ClientAuthMiddleware make users that the software access this API has basic client ID Insert a test one: Insert into client (secret) values ("123");

func ClientFromContext added in v0.4.2

func ClientFromContext(r *http.Request) *models.Client

ClientFromContext gets Client from context

func CreateHandler added in v0.1.25

func CreateHandler(typeString string, mapper datamapper.IDataMapper) func(c *gin.Context)

CreateHandler creates a resource

func CreatedTimeRangeFromQueryString added in v0.4.16

func CreatedTimeRangeFromQueryString(values *url.Values) (*int, *int, error)

func DeleteManyHandler

func DeleteManyHandler(typeString string, mapper datamapper.IDataMapper) func(c *gin.Context)

DeleteManyHandler returns a Gin handler which delete many records

func DeleteOneHandler

func DeleteOneHandler(typeString string, mapper datamapper.IDataMapper) func(c *gin.Context)

DeleteOneHandler returns a Gin handler which delete one record

func EmailChangePasswordHandler added in v0.4.18

func EmailChangePasswordHandler(typeString string, mapper datamapper.IChangeEmailPasswordMapper) func(c *gin.Context)

EmailChangePasswordHandler returns a gin handler which changes password

func EmailVerificationHandler added in v0.4.18

func EmailVerificationHandler(typeString string, mapper datamapper.IEmailVerificationMapper) func(c *gin.Context)

EmailVerificationHandler returns a gin handler which make the account verified and active

func ExpFromContext added in v0.1.58

func ExpFromContext(r *http.Request) float64

ExpFromContext gets iat from context

func GetAllHandler added in v0.4.29

func GetAllHandler(typeString string, mapper datamapper.IDataMapper) func(c *gin.Context)

GetAllHandler returns a Gin handler which fetch multiple records of a resource

func GetOptionByParsingURL added in v0.4.16

func GetOptionByParsingURL(r *http.Request) (map[urlparam.Param]interface{}, error)

func IDFromURLQueryString

func IDFromURLQueryString(c *gin.Context) (*datatypes.UUID, render.Renderer)

IDFromURLQueryString parses resource ID from the URL query string

func IatFromContext added in v0.1.58

func IatFromContext(r *http.Request) float64

IatFromContext gets iat from context

func JSONPatchesFromJSONBody added in v0.3.1

func JSONPatchesFromJSONBody(r *http.Request) ([]models.JSONIDPatch, render.Renderer)

JSONPatchesFromJSONBody pares an array of JSON patch from the HTTP body

func LatestnFromQueryString added in v0.4.16

func LatestnFromQueryString(values *url.Values) *string

func LatestnOnFromQueryString added in v0.4.30

func LatestnOnFromQueryString(values *url.Values) []string

func LimitAndOffsetFromQueryString added in v0.4.16

func LimitAndOffsetFromQueryString(values *url.Values) (*int, *int, error)

---------------------------------------------

func ModelFromJSONBody

func ModelFromJSONBody(r *http.Request, typeString string, who models.Who) (models.IModel, render.Renderer)

ModelFromJSONBody parses JSON body into a model FIXME: Validation should not be done here because empty field does not pass validation, but sometimes we need empty fields such as patch

func ModelFromJSONBodyNoWhoNoCheckPermissionNoTransform added in v0.4.23

func ModelFromJSONBodyNoWhoNoCheckPermissionNoTransform(r *http.Request, typeString string) (models.IModel, render.Renderer)

func ModelOrModelsFromJSONBody added in v0.1.24

func ModelOrModelsFromJSONBody(r *http.Request, typeString string, who models.Who) ([]models.IModel, *bool, render.Renderer)

ModelOrModelsFromJSONBody parses JSON body into array of models It take care where the case when it is not even an array and there is a "content" in there

func ModelsFromJSONBody

func ModelsFromJSONBody(r *http.Request, typeString string, who models.Who) ([]models.IModel, render.Renderer)

ModelsFromJSONBody parses JSON body into array of models

func OrderFromQueryString added in v0.4.16

func OrderFromQueryString(values *url.Values) *string

func OwnerIDFromContext

func OwnerIDFromContext(r *http.Request) *datatypes.UUID

OwnerIDFromContext gets id from context

func PasswordResetHandler added in v0.4.23

func PasswordResetHandler(typeString string, mapper datamapper.IResetPasswordMapper) func(c *gin.Context)

EmailVerificationHandler returns a gin handler which make the account verified and active

func PatchManyHandler added in v0.3.1

func PatchManyHandler(typeString string, mapper datamapper.IDataMapper) func(c *gin.Context)

PatchManyHandler returns a Gin handler which patch (partial update) many records

func PatchOneHandler

func PatchOneHandler(typeString string, mapper datamapper.IDataMapper) func(c *gin.Context)

PatchOneHandler returns a Gin handler which patch (partial update) one record

func ReadOneHandler

func ReadOneHandler(typeString string, mapper datamapper.IDataMapper) func(c *gin.Context)

ReadOneHandler returns a http.Handler which read one resource

func RenderModel added in v0.4.16

func RenderModel(w http.ResponseWriter, r *http.Request, typeString string, modelObj models.IModel, role models.UserRole, who models.Who)

RenderModel :-

func RenderModelSlice added in v0.4.16

func RenderModelSlice(w http.ResponseWriter, r *http.Request, typeString string, modelObjs []models.IModel, roles []models.UserRole, total *int, who models.Who)

RenderModelSlice :-

func ScopeFromContext added in v0.1.25

func ScopeFromContext(r *http.Request) *string

ScopeFromContext gets scope from context

func SendResetPasswordHandler added in v0.4.23

func SendResetPasswordHandler(typeString string, mapper datamapper.IResetPasswordMapper) func(c *gin.Context)

func SendVerificationEmailHandler added in v0.4.23

func SendVerificationEmailHandler(typeString string, mapper datamapper.IEmailVerificationMapper) func(c *gin.Context)

func Token

func Token(c *gin.Context)

Token handles refresh token

func TokenHoursFromContext added in v0.1.33

func TokenHoursFromContext(r *http.Request) *float64

TokenHoursFromContext gets hours from context

func UpdateManyHandler

func UpdateManyHandler(typeString string, mapper datamapper.IDataMapper) func(c *gin.Context)

UpdateManyHandler returns a Gin handler which updates many records

func UpdateOneHandler

func UpdateOneHandler(typeString string, mapper datamapper.IDataMapper) func(c *gin.Context)

UpdateOneHandler returns a http.Handler which updates a resource

func UserLoginHandler

func UserLoginHandler(typeString string) func(c *gin.Context)

UserLoginHandler logs in the user. Effectively creates a JWT token for the user

func UserRoutes

func UserRoutes(endpoint string, r *gin.Engine)

UserRoutes gets routing for user

func WhoFromContext added in v0.4.2

func WhoFromContext(r *http.Request) models.Who

WhoFromContext fetches struct Who from request context

func XDebugMiddleWare added in v0.1.33

func XDebugMiddleWare() gin.HandlerFunc

XDebugMiddleWare parses "X-DEBUG-TOKEN-DURATION-HOURS" if available

Types

type JSONBodyWithContent added in v0.1.24

type JSONBodyWithContent struct {
	Content []json.RawMessage
}

JSONBodyWithContent for partial unmarshalling

Jump to

Keyboard shortcuts

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