engine

package
v0.0.0-...-5acf4a9 Latest Latest
Warning

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

Go to latest
Published: May 18, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextOriginalPath holds the original request URL
	ContextOriginalPath key = iota
	// ContextRequestStart holds the request start time
	ContextRequestStart
	// ContextDatabase holds a reference to a data.DB database connection and services
	ContextDatabase
	// ContextAuth holds the authenticated user account id and user id
	ContextAuth
	// ContextRequestDump holds the request data
	ContextRequestDump
)

Variables

This section is empty.

Functions

func AuthenticationHandler

func AuthenticationHandler(next http.Handler) http.Handler

AuthenticationHandler middleware to check for the jwt header for every request

func GenerateJwt

func GenerateJwt(userID int) string

GenerateJwt generates a new jwt token based on the user_id

func GetKey

func GetKey() string

GetKey - returns the value from the env var APP_KEY

func GetName

func GetName() string

GetName - returns the value from the env var APP_NAME

func IsDebug

func IsDebug() bool

IsDebug - checks that the application is in debug mode

func Logger

func Logger(next http.Handler) http.Handler

Logger middleware that log request information

func ParseBody

func ParseBody(body io.ReadCloser, result interface{}) error

ParseBody parses the request body into a struct

func ResetTestMigrations

func ResetTestMigrations(source string) error

ResetTestMigrations reverts and runs every migration on /migrations folder

func Respond

func Respond(w http.ResponseWriter, r *http.Request, status int, data interface{}) error

Respond return an object with specific status as JSON

func ShiftPath

func ShiftPath(p string) (head, tail string)

ShiftPath split the request URL head and tail

func VerifyJwt

func VerifyJwt(userID int, token string) map[string]interface{}

VerifyJwt verifies that the jwt provided matches the criteria for the request

Types

type Route

type Route struct {
	// middleware
	Logger bool

	Handler http.Handler
}

Route represent a web handler with optional middlewares

Jump to

Keyboard shortcuts

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