httpcontext

package
v0.0.0-...-f39a356 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: GPL-2.0, GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentJSON       = "application/json; charset=UTF-8"
	ContentJSONStream = "application/x-json-stream; charset=UTF-8"
	ContentExcelCSV   = "application/vnd.ms-excel"
	ContentHTML       = "text/html"
)
View Source
const (
	AuthorizationHeader = "Authorization"
)

Variables

View Source
var ErrMissingToken = fmt.Errorf("No authorization header or token query parameter found")
View Source
var ErrorStackTraces = false

Functions

func DataHandle

func DataHandle(c HTTPContext, f func() (*DataResp, error), scopes ...string)

func DataHandlerFunc

func DataHandlerFunc(f func(c HTTPContext) (result *DataResp, err error), scopes ...string) http.Handler

func Handle

func Handle(c HTTPContext, f func() error, scopes ...string)

func HandlerFunc

func HandlerFunc(f func(c HTTPContext) error, scopes ...string) http.Handler

func MostAccepted

func MostAccepted(r *http.Request, name, def string) string

Types

type DataResp

type DataResp struct {
	Data        chan []interface{}
	Headers     []string
	Status      int
	ContentType string
	Filename    string
	ReportName  string
	Filters     map[string][]string
}

func (DataResp) Render

func (self DataResp) Render(c HTTPContext) error

type DefaultHTTPContext

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

func NewHTTPContext

func NewHTTPContext(w http.ResponseWriter, r *http.Request) (result *DefaultHTTPContext)

func (*DefaultHTTPContext) AccessToken

func (self *DefaultHTTPContext) AccessToken(dst utils.AccessToken) (result utils.AccessToken, err error)

func (*DefaultHTTPContext) CheckScopes

func (self *DefaultHTTPContext) CheckScopes(allowedScopes []string) (err error)

func (*DefaultHTTPContext) MostAccepted

func (self *DefaultHTTPContext) MostAccepted(name, def string) string

func (*DefaultHTTPContext) Req

func (self *DefaultHTTPContext) Req() *http.Request

func (*DefaultHTTPContext) Resp

func (*DefaultHTTPContext) Vars

func (self *DefaultHTTPContext) Vars() map[string]string

type DefaultMemorableResponseWriter

type DefaultMemorableResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func (*DefaultMemorableResponseWriter) Header

func (*DefaultMemorableResponseWriter) StartedAt

func (self *DefaultMemorableResponseWriter) StartedAt() time.Time

func (*DefaultMemorableResponseWriter) Status

func (self *DefaultMemorableResponseWriter) Status() int

func (*DefaultMemorableResponseWriter) Write

func (self *DefaultMemorableResponseWriter) Write(b []byte) (int, error)

func (*DefaultMemorableResponseWriter) WriteHeader

func (self *DefaultMemorableResponseWriter) WriteHeader(status int)

type HTTPContext

type HTTPContext interface {
	Vars() map[string]string
	Req() *http.Request
	Resp() MemorableResponseWriter
	MostAccepted(name, def string) string
	AccessToken(dst utils.AccessToken) (utils.AccessToken, error)
	CheckScopes([]string) error
}

type HTTPError

type HTTPError struct {
	Status int
	Body   interface{}
	Cause  error
	Info   string
	Stack  string
}

func NewError

func NewError(status int, body interface{}, info string, cause error) (result HTTPError)

func (HTTPError) Error

func (self HTTPError) Error() string

func (HTTPError) GetStack

func (self HTTPError) GetStack() string

func (HTTPError) GetStatus

func (self HTTPError) GetStatus() int

func (HTTPError) Respond

func (self HTTPError) Respond(c HTTPContext) (err error)

func (HTTPError) String

func (self HTTPError) String() string

type MemorableResponseWriter

type MemorableResponseWriter interface {
	http.ResponseWriter
	Status() int
	StartedAt() time.Time
}

type Responder

type Responder interface {
	Respond(c HTTPContext) error
}

type Statuserr

type Statuserr interface {
	error
	GetStatus() int
}

Jump to

Keyboard shortcuts

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