api

package
v0.0.0-...-c528fcf Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLimit  = 10
	DefaultOffset = 0
)

Variables

This section is empty.

Functions

func CorsHandler

func CorsHandler() fiber.Handler

func CreateLocationAuthzMiddleware

func CreateLocationAuthzMiddleware(authClient *auth.Client) fiber.Handler

Check if the user has rights to create a location

func DeleteLocationAuthzMiddleware

func DeleteLocationAuthzMiddleware(authClient *auth.Client) fiber.Handler

Check if the user has rights to delete a location

func ForbiddenJSONErrorResponse

func ForbiddenJSONErrorResponse(c *fiber.Ctx) error

func GetBearerTokenFromHeaders

func GetBearerTokenFromHeaders(c *fiber.Ctx) string

GetBearerTokenFromHeaders retrieves the bearer token from the headers of a fiber.Ctx object.

func GetUserIDFromCtx

func GetUserIDFromCtx(c *fiber.Ctx) string

func Protect

func Protect(authClient *auth.Client) fiber.Handler

Just a general middleware that checks for a valid JWT token

func SetUserIDOnCtx

func SetUserIDOnCtx(c *fiber.Ctx, value string)

func UnauthorizedJSONErrorResponse

func UnauthorizedJSONErrorResponse(c *fiber.Ctx) error

Types

type ErrorResponse

type ErrorResponse struct {
	Field string `json:"failed_field"`
	Tag   string `json:"tag"`
}

func ValidateStruct

func ValidateStruct(s interface{}) []*ErrorResponse

type JSONErrorResponse

type JSONErrorResponse struct {
	Message string `json:"message"`
}

type PageLimitOffset

type PageLimitOffset struct {
	Limit  int
	Offset int
}

func GetPaginationQueryParams

func GetPaginationQueryParams(c *fiber.Ctx) (*PageLimitOffset, error)

type Server

type Server struct {
	Ctx        context.Context
	App        *fiber.App
	Config     *configs.Config
	AuthClient *auth.Client
	Store      store.Store
}

func NewServer

func NewServer(ctx context.Context, c *configs.Config, s store.Store, authC *auth.Client, app *fiber.App) *Server

func (*Server) Cors

func (s *Server) Cors()

func (*Server) CreateLocation

func (s *Server) CreateLocation(c *fiber.Ctx) error

func (*Server) DeleteLocation

func (s *Server) DeleteLocation(c *fiber.Ctx) error

DeleteLocation deletes a location.

func (*Server) FindLocation

func (s *Server) FindLocation(c *fiber.Ctx) error

FindLocation finds the location based on the provided ID.

func (*Server) FindLocations

func (s *Server) FindLocations(c *fiber.Ctx) error

FindLocations retrieves a list of locations based on the provided query parameters.

func (*Server) FindLocationsByCoordinates

func (s *Server) FindLocationsByCoordinates(c *fiber.Ctx) error

FindLocationsByCoordinates finds locations by coordinates.

func (*Server) Routes

func (s *Server) Routes()

func (*Server) Start

func (s *Server) Start()

Jump to

Keyboard shortcuts

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