controllers

package
v0.0.0-...-501be23 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const TokenPayloadKey contextKey = "tokenPayload"

Variables

View Source
var ErrNoUserPayloadInContext = utils.NewHttpError(
	errors.New("could not get user payload from context"),
	http.StatusInternalServerError,
)

Functions

func GetAuthMiddleware

func GetAuthMiddleware(authService string, getToken func(r *http.Request) (string, error)) func(next http.Handler) http.Handler

func GetTokenFromHeader

func GetTokenFromHeader(r *http.Request) (string, error)

func GetTokenFromQuery

func GetTokenFromQuery(r *http.Request) (string, error)

func RegisterChatsRoutes

func RegisterChatsRoutes(router *mux.Router, service services.IChatService)

func RegisterMessagesRoutes

func RegisterMessagesRoutes(router *mux.Router, service services.IMessageService)

func RegisterParticipantRoutes

func RegisterParticipantRoutes(router *mux.Router, service services.IParticipantService)

func RegisterUsersRoutes

func RegisterUsersRoutes(router *mux.Router, service services.IUserService)

func WriteError

func WriteError(w http.ResponseWriter, err utils.HttpError)

Types

type Endpoint

type Endpoint interface {
	Handle(http.ResponseWriter, *http.Request)
	Add(*mux.Router)
}

type TokenBody

type TokenBody struct {
	Token string `json:"token"`
}

type TokenPayload

type TokenPayload struct {
	UserId int `json:"userId"`
}

Jump to

Keyboard shortcuts

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