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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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