stdapi

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2022 License: Apache-2.0 Imports: 32 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SessionExpiration = 86400 * 30
	SessionName       = ""
	SessionSecret     = ""
)

Functions

func Errorf

func Errorf(code int, format string, args ...interface{}) error

func LoadTemplates

func LoadTemplates(files FileSystem, helpers TemplateHelpers)

func Redirect

func Redirect(code int, url string) http.HandlerFunc

func RenderTemplate

func RenderTemplate(c *Context, path string, params interface{}) error

func RenderTemplatePart

func RenderTemplatePart(c *Context, path, part string, params interface{}) error

func TemplateExists

func TemplateExists(path string) bool

func UnmarshalOptions

func UnmarshalOptions(r *http.Request, opts interface{}) error

Types

type Context

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

func NewContext

func NewContext(w http.ResponseWriter, r *http.Request) *Context

func (*Context) Ajax

func (c *Context) Ajax() bool

func (*Context) Body

func (c *Context) Body() io.ReadCloser

func (*Context) BodyJSON

func (c *Context) BodyJSON(v interface{}) error

func (*Context) Context

func (c *Context) Context() context.Context

func (*Context) Flash

func (c *Context) Flash(kind, message string) error

func (*Context) Flashes

func (c *Context) Flashes() ([]Flash, error)

func (*Context) Form

func (c *Context) Form(name string) string

func (*Context) Get

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

func (*Context) Header

func (c *Context) Header(name string) string

func (*Context) IP

func (c *Context) IP() string

func (*Context) Logf

func (c *Context) Logf(format string, args ...interface{})

func (*Context) Logger

func (c *Context) Logger() *logger.Logger

func (*Context) Name

func (c *Context) Name() string

func (*Context) Protocol

func (c *Context) Protocol() string

func (*Context) Query

func (c *Context) Query(name string) string

func (*Context) Read

func (c *Context) Read(data []byte) (int, error)

func (*Context) Redirect

func (c *Context) Redirect(code int, target string) error

func (*Context) RenderJSON

func (c *Context) RenderJSON(v interface{}) error

func (*Context) RenderOK

func (c *Context) RenderOK() error

func (*Context) RenderTemplate

func (c *Context) RenderTemplate(path string, params interface{}) error

func (*Context) RenderTemplatePart

func (c *Context) RenderTemplatePart(path, part string, params interface{}) error

func (*Context) RenderText

func (c *Context) RenderText(t string) error

func (*Context) Request

func (c *Context) Request() *http.Request

func (*Context) Required

func (c *Context) Required(names ...string) error

func (*Context) Response

func (c *Context) Response() *Response

func (*Context) SessionGet

func (c *Context) SessionGet(name string) (string, error)

func (*Context) SessionSet

func (c *Context) SessionSet(name, value string) error

func (*Context) Set

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

func (*Context) SetVar

func (c *Context) SetVar(name, value string)

func (*Context) Tag

func (c *Context) Tag(format string, args ...interface{})

func (*Context) Value

func (c *Context) Value(name string) string

func (*Context) Var

func (c *Context) Var(name string) string

func (*Context) Websocket

func (c *Context) Websocket() *websocket.Conn

func (*Context) Write

func (c *Context) Write(data []byte) (int, error)

type Error

type Error interface {
	Code() int
	Error() string
}

type FileSystem

type FileSystem http.FileSystem

type Flash

type Flash struct {
	Kind    string
	Message string
}

type HandlerFunc

type HandlerFunc func(c *Context) error

func EnsureHTTPS

func EnsureHTTPS(fn HandlerFunc) HandlerFunc

type Middleware

type Middleware func(fn HandlerFunc) HandlerFunc

type RecoverFunc

type RecoverFunc func(error)

type Response

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

func (*Response) Code

func (r *Response) Code() int

func (*Response) Flush

func (r *Response) Flush()

func (*Response) WriteHeader

func (r *Response) WriteHeader(code int)

type Route

type Route struct {
	*mux.Route
	Router *Router
}

type Router

type Router struct {
	*mux.Router
	Middleware []Middleware
	Parent     *Router
	Server     *Server
}

func (*Router) HandleNotFound

func (rt *Router) HandleNotFound(fn HandlerFunc)

func (*Router) MatcherFunc

func (rt *Router) MatcherFunc(fn mux.MatcherFunc) *Router

func (*Router) Redirect

func (rt *Router) Redirect(method, path string, code int, target string)

func (*Router) Route

func (rt *Router) Route(method, path string, fn HandlerFunc) Route

func (*Router) Static

func (rt *Router) Static(path string, files FileSystem) Route

func (*Router) Subrouter

func (rt *Router) Subrouter(prefix string, fn func(*Router))

func (*Router) Use

func (rt *Router) Use(mw Middleware)

func (*Router) UseHandlerFunc

func (rt *Router) UseHandlerFunc(fn http.HandlerFunc)

type Server

type Server struct {
	Check    HandlerFunc
	Hostname string
	Logger   *logger.Logger
	Recover  RecoverFunc
	Router   *Router
	Wrapper  func(h http.Handler) http.Handler
	// contains filtered or unexported fields
}

func New

func New(ns, hostname string) *Server

func (*Server) HandleNotFound

func (s *Server) HandleNotFound(fn HandlerFunc)

func (*Server) Listen

func (s *Server) Listen(proto, addr string) error

func (*Server) MatcherFunc

func (s *Server) MatcherFunc(fn mux.MatcherFunc) *Router

func (*Server) Route

func (s *Server) Route(method, path string, fn HandlerFunc) Route

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

func (*Server) Subrouter

func (s *Server) Subrouter(prefix string, fn func(*Router)) *Router

func (*Server) Use

func (s *Server) Use(mw Middleware)

func (*Server) UseHandlerFunc

func (s *Server) UseHandlerFunc(fn http.HandlerFunc)

type TemplateHelpers

type TemplateHelpers func(c *Context) template.FuncMap

Jump to

Keyboard shortcuts

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