route

package module
v0.0.0-...-782cc17 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SessionID

func SessionID(req *http.Request, name string) string

Types

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

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) BasicAuth

func (r *Request) BasicAuth(auth BasicAuth) bool

func (*Request) ClearCookie

func (r *Request) ClearCookie(name, path string)

func (*Request) ClearSession

func (r *Request) ClearSession(name string)

func (*Request) Done

func (r *Request) Done() bool

func (*Request) Fail

func (r *Request) Fail(e Error)

func (*Request) Header

func (r *Request) Header() http.Header

func (*Request) Meditation

func (r *Request) Meditation() string

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) ParamDuration

func (r *Request) ParamDuration(name string) *time.Duration

ParamDuration parses a duration string, example: "1m30s" that will be 1 minute and 30 seconds

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) Redirect

func (r *Request) Redirect(code int, to string)

func (*Request) RemoteIP

func (r *Request) RemoteIP() string

func (*Request) Respond

func (r *Request) Respond(code int, typ, msg string, args ...interface{})

func (*Request) SessionID

func (r *Request) SessionID(name string) string

func (*Request) SetCookie

func (r *Request) SetCookie(name, val, path string)

func (*Request) SetSession

func (r *Request) SetSession(name, id string)

func (*Request) Stream

func (r *Request) Stream(in io.Reader)

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(settings WebSocketSettings) *WebSocket

func (*Request) UserAgent

func (r *Request) UserAgent() string

type Router

type Router struct {
	Name  string
	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(onclose func())

func (*WebSocket) Ping

func (ws *WebSocket) Ping() error

func (*WebSocket) SendClose

func (ws *WebSocket) SendClose() error

func (*WebSocket) Write

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

type WebSocketSettings

type WebSocketSettings struct {
	WriteTimeout time.Duration
}

Jump to

Keyboard shortcuts

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