app

package
v0.0.0-...-1402125 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MyClaims

type MyClaims struct {
	ID uuid.UUID `json:"id"`
	jwt.StandardClaims
}

MyClaims struct defined for adding to jwt.StandardClaims as an embedded type.

type Server

type Server struct {
	DB     models.Datastore
	Router *hr.Router
	Log    *logs.Log
}

Server struct includes our datastore, router, and logger. All handlers hang off this Server struct to access its components via dependency injection as needed.

func (*Server) CSRFErrorHandler

func (s *Server) CSRFErrorHandler() http.Handler

CSRFErrorHandler is a custom error handler when CSRF tokens come in invalid

func (*Server) LogRequests

func (s *Server) LogRequests(next http.Handler) http.Handler

LogRequests logs the custom request ID (created in the SPA), URI, and method to the logger.

func (*Server) NewLimiter

func (s *Server) NewLimiter() *limiter.Limiter

NewLimiter sets up tollbooth rate limiter

func (*Server) Routes

func (s *Server) Routes()

Routes initiates our Server's routes

func (*Server) SetHeaders

func (s *Server) SetHeaders(next http.Handler) http.Handler

SetHeaders sets the CSRF Token for all responses

func (*Server) Timeout

func (s *Server) Timeout(next http.Handler) http.Handler

Timeout sets a context withcancel that matches &http.Server read + write timeout in main.go. This middleware allows the handlers to respond precisely to timeout errors while the &http.Server timeout serves as an absolute safeguard.

Jump to

Keyboard shortcuts

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