api

package
v0.0.0-...-0cdf6b9 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The user identity key for JWT middleware
	KEY_USERID = "userid"

	APIHealthCheckRoute string = "/check"

	LoginRoute string = "/login"

	// Identifiers for the user in claims/context
	USER_ID_KEY        string = "id"
	USER_SESSION_TOKEN string = "sessiontoken"

	// For identifying the content type in Content-Type header
	ContentTypeJSON string = "application/json; charset=utf-8"
)
View Source
const (
	MessageRoute  string = "/message"
	MessagesRoute string = "/messages"
)
View Source
const (
	UserRoute  string = "/user"
	UsersRoute string = "/users"
)

Variables

This section is empty.

Functions

func AddAdditionalRoutes

func AddAdditionalRoutes(r *gin.Engine, authMiddleware *jwt.GinJWTMiddleware) *gin.Engine

func AddHealthCheckRoutes

func AddHealthCheckRoutes(r *gin.Engine) *gin.Engine

func AddMessageRoutes

func AddMessageRoutes(r *gin.Engine, authMiddleware *jwt.GinJWTMiddleware) *gin.Engine

func AddUserRoutes

func AddUserRoutes(r *gin.Engine, authMiddleware *jwt.GinJWTMiddleware) *gin.Engine

func GetAuthMiddleware

func GetAuthMiddleware() (*jwt.GinJWTMiddleware, error)

func GetIDFromClaim

func GetIDFromClaim(c *gin.Context) int

Get the user ID from the claim in the JWT

func GetSessionTokenFromClaim

func GetSessionTokenFromClaim(c *gin.Context) string

Get the session token from the claim in the JWT

func HandleHealthCheckRequest

func HandleHealthCheckRequest(c *gin.Context)

func HandleMessageCreateRequest

func HandleMessageCreateRequest(c *gin.Context)

func HandleMessagesRequest

func HandleMessagesRequest(c *gin.Context)

func HandleUserCreateRequest

func HandleUserCreateRequest(c *gin.Context)

func InitRouter

func InitRouter() *gin.Engine

Initialize the router

func ReplyBadRequest

func ReplyBadRequest(c *gin.Context, msg string)

func ReplyForbidden

func ReplyForbidden(c *gin.Context, msg string)

func ReplyInternalServerError

func ReplyInternalServerError(c *gin.Context, msg string)

func ReplyNotFound

func ReplyNotFound(c *gin.Context, msg string)

func ReplyUnprocessableEntity

func ReplyUnprocessableEntity(c *gin.Context, msg string)

USES:

  • The payload was correctly formed, but could not be marshalled into the JSON struct

func SetCrossOrigin

func SetCrossOrigin(r *gin.Engine) *gin.Engine

func ValidatePassword

func ValidatePassword(plain_password string) bool

--- Utility Functions ---

Types

This section is empty.

Jump to

Keyboard shortcuts

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