nova

package module
v0.0.0-...-6844d99 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2018 License: MIT Imports: 2 Imported by: 6

README

nova

Build Status

core of novaKIT, a minimized golang web framework

donation

BMC

Documentation

Index

Constants

View Source
const (
	// Production production env value
	Production = Env("production")

	// Development development env value
	Development = Env("development")

	// Test test env value
	Test = Env("test")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// Env environment
	Env Env
	// Handlers the handlers
	Handlers []HandlerFunc
	// ErrorHandler must not be nil
	ErrorHandler ErrorHandlerFunc
	// Req the http request
	Req *http.Request
	// Res the http response writer
	Res http.ResponseWriter
	// Values pre-request associated values
	Values map[string]interface{}
	// contains filtered or unexported fields
}

Context per-request context

func (*Context) Next

func (c *Context) Next()

Next invoke the next HandlerFunc registered in application

type Env

type Env string

Env empty-safe environment string

func (Env) IsDevelopment

func (e Env) IsDevelopment() bool

IsDevelopment is development, if empty returns true

func (Env) IsProduction

func (e Env) IsProduction() bool

IsProduction is production

func (Env) IsTest

func (e Env) IsTest() bool

IsTest is test

func (Env) String

func (e Env) String() string

String convert to string

type ErrorHandlerFunc

type ErrorHandlerFunc func(*Context, error)

ErrorHandlerFunc functions handles a pre-request context and a error

type HandlerFunc

type HandlerFunc func(*Context) error

HandlerFunc function handles a per-request context and returns error

type Nova

type Nova struct {
	// Env environment must be one of "production", "development", "test"
	Env Env
	// Handlers slice of handler functions
	Handlers []HandlerFunc
	// ErrorHandler handler will be invoked on error returned by previous handlers
	ErrorHandler ErrorHandlerFunc
}

Nova application

func New

func New() *Nova

New create a new instance of Nova

func (*Nova) CreateContext

func (n *Nova) CreateContext(res http.ResponseWriter, req *http.Request) *Context

CreateContext create a nova.context from http.Request / http.ResponseWriter

func (*Nova) Error

func (n *Nova) Error(handler ErrorHandlerFunc)

ErrorHandler register a error handler

func (*Nova) ServeHTTP

func (n *Nova) ServeHTTP(res http.ResponseWriter, req *http.Request)

ServeHTTP implements http.HandlerFunc

func (*Nova) Use

func (n *Nova) Use(handlers ...HandlerFunc)

Use add mutiple handler functions

Jump to

Keyboard shortcuts

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