route

package
v8.0.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2018 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SessionHeaderKey = "X-Shield-Session"
	SessionCookieKey = "shield7"
)

Variables

This section is empty.

Functions

func SessionID

func SessionID(req *http.Request) string

Types

type Error

type Error struct {
	Diagnostic string   `json:"diagnostic,omitempty"`
	Message    string   `json:"error,omitempty"`
	Missing    []string `json:"missing,omitempty"`
	// contains filtered or unexported fields
}

func Bad

func Bad(e error, msg string, args ...interface{}) Error

func Errorf

func Errorf(code int, e error, msg string, args ...interface{}) Error

func Forbidden

func Forbidden(e error, msg string, args ...interface{}) Error

func NotFound

func NotFound(e error, msg string, args ...interface{}) Error

func Oops

func Oops(e error, msg string, args ...interface{}) Error

func Unauthorized

func Unauthorized(e error, msg string, args ...interface{}) Error

func (Error) Error

func (e Error) Error() string

func (*Error) ProvideDiagnostic

func (e *Error) ProvideDiagnostic()

type Handler

type Handler func(r *Request)

type Request

type Request struct {
	Req  *http.Request
	Args []string
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(w http.ResponseWriter, r *http.Request, debug bool) *Request

NewRequest initializes and returns a new request object. Setting debug to true will cause errors to be logged.

func (*Request) Fail

func (r *Request) Fail(e Error)

func (*Request) Missing

func (r *Request) Missing(params ...string) bool

func (*Request) OK

func (r *Request) OK(resp interface{})

func (*Request) Param

func (r *Request) Param(name, def string) string

func (*Request) ParamDate

func (r *Request) ParamDate(name string) *time.Time

func (*Request) ParamIs

func (r *Request) ParamIs(name, want string) bool

func (*Request) Payload

func (r *Request) Payload(v interface{}) bool

Payload unmarshals the JSON body of this request into the given interface. Returns true if successful and false otherwise.

func (*Request) SessionID

func (r *Request) SessionID() string

func (*Request) SetCookie

func (r *Request) SetCookie(cookie *http.Cookie)

func (*Request) SetRespHeader

func (r *Request) SetRespHeader(header, value string)

func (*Request) String

func (r *Request) String() string

func (*Request) Success

func (r *Request) Success(msg string, args ...interface{})

func (*Request) Upgrade

func (r *Request) Upgrade() *WebSocket

type Router

type Router struct {
	Debug bool
	// contains filtered or unexported fields
}

func (*Router) Dispatch

func (r *Router) Dispatch(match string, handler Handler)

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

type WebSocket

type WebSocket struct {
	// contains filtered or unexported fields
}

func (*WebSocket) Discard

func (ws *WebSocket) Discard()

func (*WebSocket) Write

func (ws *WebSocket) Write(b []byte) error

Jump to

Keyboard shortcuts

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