api

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package api contains functions and data for a functional permissions-api server.

Index

Constants

This section is empty.

Variables

View Source
var (
	// MaxPaginationSize represents the maximum number of records that can be returned per page
	MaxPaginationSize = 1000
	// DefaultPaginationSize represents the default number of records that are returned per page
	DefaultPaginationSize = 100
)
View Source
var (
	// ErrNoActionDefined is the error returned when an access request is has no action defined
	ErrNoActionDefined = errors.New("no action defined")

	// ErrAccessDenied is returned when access is denied
	ErrAccessDenied = errors.New("access denied")
)
View Source
var (
	// ErrResourceNotFound is returned when the requested resource isn't found
	ErrResourceNotFound = errors.New("resource not found")

	// ErrSearchNotFound is returned when the requested search term isn't found
	ErrSearchNotFound = errors.New("search term not found")

	// ErrResourceAlreadyExists is returned when the resource already exists
	ErrResourceAlreadyExists = errors.New("resource already exists")
)

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message,omitempty"`
	Error   string `json:"error,omitempty"`
}

ErrorResponse represents the data that the server will return on any given call

type Option added in v0.2.0

type Option func(r *Router) error

Option defines a router option function.

func WithCheckConcurrency added in v0.2.0

func WithCheckConcurrency(count int) Option

WithCheckConcurrency sets the check concurrency for bulk permission checks.

func WithLogger added in v0.2.0

func WithLogger(logger *zap.SugaredLogger) Option

WithLogger sets the logger for the router.

type Pagination

type Pagination struct {
	Limit int
	Page  int
	Order string
}

Pagination allow you to paginate the results

func ParsePagination

func ParsePagination(c echo.Context) *Pagination

ParsePagination parses the pagination query parameters from the echo context

func (*Pagination) SetHeaders

func (p *Pagination) SetHeaders(c echo.Context, count int)

SetHeaders sets the pagination headers on a response

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router provides a router for the API

func NewRouter

func NewRouter(authCfg echojwtx.AuthConfig, engine query.Engine, options ...Option) (*Router, error)

NewRouter returns a new api router

func (*Router) Routes

func (r *Router) Routes(rg *echo.Group)

Routes will add the routes for this API version to a router group

Jump to

Keyboard shortcuts

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