middlewares

package
v0.0.0-...-04c0119 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouter

func NewRouter(r *Repository)

NewHandlers sets the Repo.

Types

type Repository

type Repository struct {
	App *config.AppConfig
	DB  database.DatabaseRepo
}

Repository is the router repository type.

var Repo *Repository

Repo is the router repository.

func NewMongoDBRepo

func NewMongoDBRepo(a *config.AppConfig, db *mongo.Database) *Repository

NewMongoDBRepo returns a new instance of a repository for the mongo driver.

func NewTestRepo

func NewTestRepo(a *config.AppConfig) *Repository

NewTestDBRepo returns a new repository for testing purposes.

func (*Repository) Auth

func (m *Repository) Auth(next http.Handler) http.Handler

Auth checks if the requests is authorized to access the endpoint.

func (*Repository) IsPostCreatorOrAdmin

func (m *Repository) IsPostCreatorOrAdmin(next http.Handler) http.Handler

IsPostCreatorOrAdmin is a middleware to check if the user got the permission to modify or delete the target post.

func (*Repository) IsUserOrAdmin

func (m *Repository) IsUserOrAdmin(next http.Handler) http.Handler

IsUserOrAdmin is a middleware to check if the user got the permission to change or delete the target user.

Jump to

Keyboard shortcuts

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