api

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JwtExpirationHoursDefault the default expiration of JWTs in hours
	JwtExpirationHoursDefault = 3
)

Variables

This section is empty.

Functions

func AddRouter added in v1.1.0

func AddRouter(config *apiConfig.HTTPConfig, db *gorm.DB) (*mux.Router, error)

AddRouter returns a new router based on the API configuration. Leverages database for handlers

func Logger

func Logger(inner http.Handler, name string) http.Handler

Logger adds a handler for the logger

func NewRouter

func NewRouter(config *config.HTTPConfig, db *gorm.DB) *mux.Router

NewRouter returns a new router

Types

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

Route handles the routes for the API map a method and pattern to the appropriate handler

type Routes

type Routes []Route

Routes slice of routes

type Server added in v1.1.0

type Server struct {
	*http.Server
	DB     *gorm.DB
	Config *apiConfig.HTTPConfig
}

Server represents an API server

func NewServer added in v1.1.0

func NewServer(config *apiConfig.HTTPConfig, db *gorm.DB) (*Server, error)

NewServer returns a new API server with middleware and route

func (*Server) Start added in v1.1.0

func (srv *Server) Start()

Start runs ListenAndServe on the http.Server with graceful shutdown.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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