web

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2022 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	*karma.Context
	// contains filtered or unexported fields
}

func NewContext

func NewContext(
	writer http.ResponseWriter,
	request *http.Request,
	templates *template.Template,
) *Context

func (*Context) BadRequest

func (context *Context) BadRequest(
	err error,
	message string,
	values ...interface{},
) Status

func (*Context) Describe

func (context *Context) Describe(key string, value string) *Context

func (*Context) Error

func (context *Context) Error(
	code int,
	err error,
	message string,
	values ...interface{},
) Status

func (*Context) Get

func (context *Context) Get(name string) interface{}

func (*Context) GetBody

func (context *Context) GetBody() io.ReadCloser

func (*Context) GetID

func (context *Context) GetID() string

func (*Context) GetQueryParam

func (context *Context) GetQueryParam(key string) string

func (*Context) GetRequest

func (context *Context) GetRequest() *http.Request

func (*Context) GetResponseWriter

func (context *Context) GetResponseWriter() http.ResponseWriter

func (*Context) GetStatus

func (context *Context) GetStatus() Status

func (*Context) GetURL

func (context *Context) GetURL() *url.URL

func (*Context) GetURLParam

func (context *Context) GetURLParam(key string) string

func (*Context) InternalError

func (context *Context) InternalError(
	err error,
	message string,
	values ...interface{},
) Status

func (*Context) JSON

func (context *Context) JSON(code int, response interface{}) Status

func (*Context) NotFound

func (context *Context) NotFound() Status

func (*Context) OK

func (context *Context) OK() Status

func (*Context) Redirect

func (context *Context) Redirect(location string) Status

func (*Context) Render

func (context *Context) Render(name string) Status

func (*Context) Set

func (context *Context) Set(name string, value interface{}) *Context

func (*Context) SetResponseWriter

func (context *Context) SetResponseWriter(writer http.ResponseWriter)

func (*Context) SetStatus

func (context *Context) SetStatus(status Status)

func (*Context) Write

func (context *Context) Write(body []byte) (int, error)

type ContextKey

type ContextKey string

type Handler

type Handler func(*Context) Status

type Status

type Status struct {
	Code  int
	Error error
	Body  []byte
}

type Web

type Web struct {
	*chi.Mux
	// contains filtered or unexported fields
}

func New

func New() *Web

func (*Web) Group

func (web *Web) Group() *Web

func (*Web) LoadTemplates

func (web *Web) LoadTemplates(directory string, funcs template.FuncMap) error

func (*Web) RedirectSlashes

func (web *Web) RedirectSlashes(exclude ...string) func(http.Handler) http.Handler

func (*Web) ServeDirectory

func (web *Web) ServeDirectory(dir string, prefix string) http.HandlerFunc

func (*Web) ServeFunc

func (web *Web) ServeFunc(handler Handler) http.HandlerFunc

func (*Web) ServeResources

func (web *Web) ServeResources(prefix string) http.HandlerFunc

func (*Web) ServeTemplate

func (web *Web) ServeTemplate(name string) http.HandlerFunc

func (*Web) ServeTemplateWithData

func (web *Web) ServeTemplateWithData(
	name string,
	data map[string]interface{},
) http.HandlerFunc

func (*Web) SetResourcesDir

func (web *Web) SetResourcesDir(dir string) error

func (*Web) Static

func (web *Web) Static(path string)

func (*Web) Use

func (web *Web) Use(middleware func(Handler) Handler)

Jump to

Keyboard shortcuts

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