router

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package router provides functionality to set up and run the HTTP server, manage routes, and apply middleware based on access levels.

It configures and initializes routes with varying access requirements: - Public routes: Accessible without authentication. - Protected routes: Require authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr                     string            // Address to listen on
	BaseURL                  string            // Base URL for API routes
	RestfullControllers      []api.IController // List of controllers
	GraphQlController        http.Handler
	AuthorizationMiddleware  func(http.Handler) http.Handler
	PopulateClaimsMiddleware func(http.Handler) http.Handler
	RateLimitMiddleware      func(http.Handler) http.Handler
}

Config holds configuration settings for creating a new Router instance.

type Router

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

Router manages the HTTP server and its dependencies, including controllers and JWT authentication.

func NewRouter

func NewRouter(config Config) *Router

NewRouter creates a new Router instance with the given configuration. It initializes the router with address, base URL, controllers, and JWT service.

func (*Router) Run

func (r *Router) Run() error

Run starts the HTTP server and sets up routes with different access levels.

Routes are grouped and managed under the base URL, with the following access levels: - Public routes: No authentication required. - Protected routes: Authentication required.

Jump to

Keyboard shortcuts

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