roboot

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: MIT Imports: 8 Imported by: 0

README

Roboot

Roboot is a micro web framework for Go.

Documentation

Documentation can be found at Godoc.

LICENSE

MIT.

Documentation

Index

Constants

View Source
const (
	HeaderAccept          = "Accept"
	HeaderAcceptEncoding  = "Accept-Encoding"
	HeaderContentEncoding = "Content-Encoding"
	HeaderContentType     = "Content-Type"
	HeaderContentLength   = "Content-Length"
	HeaderUserAgent       = "User-Agent"

	HeaderAuthorization = "Authorization"

	ContentEncodingGzip    = "gzip"
	ContentEncodingDeflate = "deflate"

	HeaderOrigin = "Origin"

	// CORS
	HeaderCorsRequestMethod  = "Access-Control-Request-Method"
	HeaderCorsRequestHeaders = "Access-Control-Request-Headers"

	HeaderCorsAllowOrigin      = "Access-Control-Allow-Origin"
	HeaderCorsAllowCredentials = "Access-Control-Allow-Credentials"
	HeaderCorsAllowHeaders     = "Access-Control-Allow-Headers"
	HeaderCorsAllowMethods     = "Access-Control-Allow-Methods"
	HeaderCorsExposeHeaders    = "Access-Control-Expose-Headers"
	HeaderCorsMaxAge           = "Access-Control-Max-Age"
)
View Source
const (
	MethodGet     = "GET"
	MethodPost    = "POST"
	MethodDelete  = "DELETE"
	MethodPut     = "PUT"
	MethodPatch   = "PATCH"
	MethodHead    = "HEAD"
	MethodOptions = "OPTIONS"
	MethodConnect = "CONNECT"
	MethodTrace   = "TRACE"
)

Variables

View Source
var ErrHijack = errors.New("response is not hijackable")

Functions

This section is empty.

Types

type Codec

type Codec interface {
	ContentType() string
	Marshal(interface{}) ([]byte, error)
	NewEncoder(io.Writer) Encoder
	Encode(io.Writer, interface{}) error
	Unmarshal([]byte, interface{}) error
	NewDecoder(io.Reader) Decoder
	Decode(io.Reader, interface{}) error
}

==============================================================================

Env

==============================================================================

type Context

type Context struct {
	Req   *http.Request
	Resp  ResponseWriter
	Codec Codec
	// contains filtered or unexported fields
}

==============================================================================

Context

==============================================================================

func (*Context) BodyValue

func (ctx *Context) BodyValue(name string) string

func (*Context) BodyValues

func (ctx *Context) BodyValues(name string) []string

func (*Context) ContextValue

func (ctx *Context) ContextValue(name string) interface{}

func (*Context) Decode

func (ctx *Context) Decode(obj interface{}) error

func (*Context) Encode

func (ctx *Context) Encode(obj interface{}, status int)

func (*Context) Env

func (ctx *Context) Env() *Env

func (*Context) Error

func (ctx *Context) Error(err error, statusCode int)

func (*Context) File

func (ctx *Context) File(name string) *multipart.FileHeader

func (*Context) Files

func (ctx *Context) Files(name string) []*multipart.FileHeader

func (*Context) GetCodec

func (ctx *Context) GetCodec() Codec

func (*Context) ParamValue

func (ctx *Context) ParamValue(name string) string

func (*Context) QueryValue

func (ctx *Context) QueryValue(name string) string

func (*Context) QueryValues

func (ctx *Context) QueryValues(name string) []string

func (*Context) Render

func (ctx *Context) Render(name string, v interface{})

func (*Context) SetContextValue

func (ctx *Context) SetContextValue(name string, val interface{})

func (*Context) Status

func (ctx *Context) Status(code int)

type Decoder

type Decoder interface {
	Decode(interface{}) error
}

==============================================================================

Env

==============================================================================

type Encoder

type Encoder interface {
	Encode(interface{}) error
}

==============================================================================

Env

==============================================================================

type Env

type Env struct {
	// cant't be nil
	Codec Codec
	Error ErrorHandler

	FileUpload struct {
		MaxMemory int64
	}
	Renderer Renderer
}

==============================================================================

Env

==============================================================================

type ErrType

type ErrType uint8

==============================================================================

Env

==============================================================================

const (
	ErrTypeParseQuery ErrType = iota + 1
	ErrTypeParseForm
	ErrTypeParseMultipartForm
	ErrTypePanic
	ErrTypeHandle
	ErrTypeRender
	ErrTypeEncode
)

func (ErrType) String

func (e ErrType) String() string

type ErrorHandler

type ErrorHandler interface {
	Log(ctx *Context, errType ErrType, err error)
	Handle(ctx *Context, callerDepth, status int, err error)
}

==============================================================================

Env

==============================================================================

type Filter

type Filter interface {
	Filter(ctx *Context, chain Handler)
}

==============================================================================

Handler

==============================================================================

type FilterFunc

type FilterFunc func(ctx *Context, chain Handler)

==============================================================================

Handler

==============================================================================

func (FilterFunc) Filter

func (f FilterFunc) Filter(ctx *Context, chain Handler)

type Handler

type Handler interface {
	Handle(*Context)
}

==============================================================================

Handler

==============================================================================

type HandlerFunc

type HandlerFunc func(*Context)

==============================================================================

Handler

==============================================================================

func (HandlerFunc) Handle

func (f HandlerFunc) Handle(ctx *Context)

type MatchedFilter

type MatchedFilter struct {
	Filter
	Params
}

==============================================================================

Handler

==============================================================================

type MatchedHandler

type MatchedHandler struct {
	Handler
	Params
}

==============================================================================

Handler

==============================================================================

type Params

type Params interface {
	Len() int
	Get(name string) string
}

==============================================================================

Context

==============================================================================

type Renderer

type Renderer interface {
	Render(io.Writer, string, interface{}) error
}

==============================================================================

Env

==============================================================================

type ResponseWriter

type ResponseWriter interface {
	StatusCode() int
	http.ResponseWriter
}

==============================================================================

Context

==============================================================================

type Router

type Router interface {
	Handle(path string, handler Handler) error
	Filter(path string, filters ...Filter) error
	Group(prefix string) Router
	Merge(prefix string, r Router) error

	MatchHandler(path string) MatchedHandler
	MatchFilters(path string) []MatchedFilter
	MatchHandlerAndFilters(path string) (MatchedHandler, []MatchedFilter)
}

==============================================================================

Handler

==============================================================================

type Server

type Server interface {
	Env() *Env
	Router(h string) Router
	Host(h string, r Router)
	http.Handler
}

==============================================================================

Server

==============================================================================

func NewServer

func NewServer(env Env, defaultRouter Router) Server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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