common

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2018 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPError

type HTTPError struct {
	// Message to log in console
	Message string
	// Status code that'll be sent in response
	StatusCode int
}

HTTPError is any error that occurs in middlewares or the code that handles HTTP Frontend of application Message is logged to console and Status Code is sent in response If a Middleware sends an HTTPError, No middlewares further up in chain are executed

func ReadAndServeFile

func ReadAndServeFile(name string, w http.ResponseWriter) *HTTPError

ReadAndServeFile reads the file from specified location and sends it in response

type Handler

type Handler func(rc *RouterContext, w http.ResponseWriter, r *http.Request) *HTTPError

Handler is the signature of HTTP Handler that is passed to Handle function

type RouterContext

type RouterContext struct {
	User *User
}

RouterContext contains any information to be shared with middlewares.

type User

type User struct {
	Username string `json:"username"`
}

User struct denotes the data is stored in the cookie

Jump to

Keyboard shortcuts

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