uhttp

package module
v1.0.34 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2019 License: MIT Imports: 12 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddContext

func AddContext(key string, value interface{})

func AddContexts

func AddContexts(m ContextMap)

func AddMiddleware

func AddMiddleware(mw Middleware)

func Handle

func Handle(pattern string, handler Handler)

Handle configuration

func ParsedModel

func ParsedModel(r *http.Request) interface{}

func RealIP added in v1.0.33

func RealIP(r *http.Request) string

func Render

func Render(w http.ResponseWriter, r *http.Request, model interface{})

func RenderError

func RenderError(w http.ResponseWriter, r *http.Request, err error)

func RenderErrorWithStatusCode

func RenderErrorWithStatusCode(w http.ResponseWriter, r *http.Request, statusCode int, err error)

func RenderMessage

func RenderMessage(w http.ResponseWriter, r *http.Request, msg string)

func RenderMessageWithStatusCode

func RenderMessageWithStatusCode(w http.ResponseWriter, r *http.Request, statusCode int, msg string)

func RenderWithStatusCode

func RenderWithStatusCode(w http.ResponseWriter, r *http.Request, statusCode int, model interface{})

func SelectMethod

func SelectMethod(chain Middleware, handler Handler) http.HandlerFunc

func ServeSinglePageApp

func ServeSinglePageApp(path string, mainHTMLFile string)

ServeSinglePageApp <-

func SetConfig

func SetConfig(_config Config)

SetConfig set config for all handlers

Types

type Config

type Config struct {
	CORS      *string
	CustomLog ulog.ULogger
}

func GetConfig

func GetConfig() Config

type ContextMap

type ContextMap map[string]interface{}

func RequestContext

func RequestContext() ContextMap

type Handler

type Handler struct {
	Pattern        string
	PostHandler    http.HandlerFunc
	PostModel      interface{}
	GetHandler     http.HandlerFunc
	GetModel       interface{}
	DeleteHandler  http.HandlerFunc
	DeleteModel    interface{}
	RequiredGet    params.R
	OptionalGet    params.R
	AddMiddlewares []Middleware
	AddMiddleware  *Middleware
	PreProcess     func(ctx context.Context) error
}

Handler configured

func (Handler) HandlerFunc

func (h Handler) HandlerFunc() http.HandlerFunc

func (Handler) WsReady added in v1.0.32

func (h Handler) WsReady() Middleware

type Middleware

type Middleware func(next http.HandlerFunc) http.HandlerFunc

func AdditionalMiddlewares

func AdditionalMiddlewares() []Middleware

func Chain

func Chain(mw ...Middleware) Middleware

Chain chain multiple middlewares copied from: https://hackernoon.com/simple-http-middleware-with-go-79a4ad62889b

Directories

Path Synopsis
cli module
uhttpcli module

Jump to

Keyboard shortcuts

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