Documentation ¶
Index ¶
- type App
- func (a *App) Add(method Method, path string, params string, handler HandlerFunc, ...)
- func (a *App) Delete(path string, params string, handler HandlerFunc)
- func (a *App) Get(path string, params string, handler HandlerFunc)
- func (a *App) Head(path string, params string, handler HandlerFunc)
- func (a *App) LoadHTMLFiles(f ...string)
- func (a *App) LoadHTMLGlob(p string)
- func (a *App) Options(path string, params string, handler HandlerFunc)
- func (a *App) Patch(path string, params string, handler HandlerFunc)
- func (a *App) Post(path string, params string, handler HandlerFunc)
- func (a *App) Put(path string, params string, handler HandlerFunc)
- func (a *App) Route(r Route)
- func (a *App) Run()
- func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (a *App) Service(s Service)
- func (a *App) SetHTMLTemplate(t *template.Template)
- func (a *App) Shutdown(f ...ShutdownFunc)
- func (a *App) Use(m ...MiddlewareFunc)
- type Config
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortWithError(s int, e error)
- func (c *Context) AbortWithStatus(s int)
- func (c *Context) Aborted() bool
- func (c *Context) BindJSON(a any) error
- func (c *Context) BindTOML(a any) error
- func (c *Context) BindXML(a any) error
- func (c *Context) BindYAML(a any) error
- func (c *Context) Body() ([]byte, error)
- func (c *Context) Cookie(n string) (string, error)
- func (c *Context) Copy() *Context
- func (c *Context) Decorator() DecoratorFunc
- func (c *Context) Error(err errs.Error)
- func (c *Context) ErrorLog(err errs.Error)
- func (c *Context) FormFile(n string) (*multipart.FileHeader, error)
- func (c *Context) Get(k string) (any, bool)
- func (c *Context) GetFile(p string)
- func (c *Context) GetHeader(k string) string
- func (c *Context) HTML(s int, n string, d any)
- func (c *Context) Handler() HandlerFunc
- func (c *Context) Header(k string, v string)
- func (c *Context) JSON(s int, b any)
- func (c *Context) Method() Method
- func (c *Context) MultipartForm() (*multipart.Form, error)
- func (c *Context) MustBindWith(a any, b binding.Binder) error
- func (c *Context) MustGet(k string) (any, error)
- func (c *Context) MustSet(k string, v string) error
- func (c *Context) Param(k string) (string, error)
- func (c *Context) ParamAll() (map[string]string, error)
- func (c *Context) ParamBool(k string) (bool, error)
- func (c *Context) ParamFloat(k string) (float64, error)
- func (c *Context) ParamInt(k string) (int, error)
- func (c *Context) Path() string
- func (c *Context) Protocol() string
- func (c *Context) Query(k string) (string, error)
- func (c *Context) QueryAll() (map[string]string, error)
- func (c *Context) QueryBool(k string) (bool, error)
- func (c *Context) QueryFloat(k string) (float64, error)
- func (c *Context) QueryInt(k string) (int, error)
- func (c *Context) Redirect(s int, l string)
- func (c *Context) Render(s int, b string)
- func (c *Context) RenderBytes(s int, b []byte)
- func (c *Context) RequestAddress() (string, error)
- func (c *Context) Reset()
- func (c *Context) Route() *Route
- func (c *Context) SaveFile(f *multipart.FileHeader, p string) error
- func (c *Context) Secure() bool
- func (c *Context) Set(k string, v any)
- func (c *Context) ShouldBindJSON(a any) error
- func (c *Context) ShouldBindTOML(a any) error
- func (c *Context) ShouldBindWith(a any, b binding.Binder) error
- func (c *Context) ShouldBindXML(a any) error
- func (c *Context) ShouldBindYAML(a any) error
- func (c *Context) Status(s int)
- func (c *Context) String(s int, f string, v ...any)
- func (c *Context) TOML(s int, b any)
- func (c *Context) Write(s string) (int, error)
- func (c *Context) WriteBytes(body []byte) (int, error)
- func (c *Context) XML(s int, b any)
- func (c *Context) YAML(s int, b any)
- type DecoratorFunc
- type HTML
- type HTMLDebug
- type HTMLDelims
- type HTMLRender
- type HTMLRenderer
- type HandlerFunc
- type M
- type Method
- type MiddlewareFunc
- type Redirect
- type Renderer
- type Route
- type Service
- type ShutdownFunc
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App struct
routes: array containg all Route structs
port: string port
logger: structured logging
debugMode: if debugMode is enabled things such as HTML as less static, will be slower but easier to debug.
corsMode: if localhost, 127.0.0.1 or no origin do not allow this request.
htmlDelims: HTML Delimiters, these can be customized.
htmlRender: HTML Renderer, an interface that renders the HTML to the user.
funcMap: templates.FuncMap
func (*App) Add ¶
func (a *App) Add(method Method, path string, params string, handler HandlerFunc, decorator DecoratorFunc)
Add a Route with the method, path, params, handler and decorator
func (*App) Delete ¶
func (a *App) Delete(path string, params string, handler HandlerFunc)
Add Delete route
func (*App) Head ¶
func (a *App) Head(path string, params string, handler HandlerFunc)
Add Head route
func (*App) Options ¶
func (a *App) Options(path string, params string, handler HandlerFunc)
Add Options route
func (*App) Patch ¶
func (a *App) Patch(path string, params string, handler HandlerFunc)
Add Patch route
func (*App) Post ¶
func (a *App) Post(path string, params string, handler HandlerFunc)
Add Post route
func (*App) ServeHTTP ¶
func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServerHTTP with ResponseWriter and Request
func (*App) SetHTMLTemplate ¶
Set the current HTML renderer.
func (*App) Shutdown ¶
func (a *App) Shutdown(f ...ShutdownFunc)
Shutdown the App, should be ran as go Shutdown()
func (*App) Use ¶
func (a *App) Use(m ...MiddlewareFunc)
type Config ¶
Configure routey
Port: what port do you want routey to use?
Debug: do you want routey to run in debug mode?
CORS: do you want to run this in local only mode?
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
A Context provides
writer: write data back to the user
request: request data that was given
params: the parameters of the request
queryCache: a cache of queries for this request
queryCached: has the queryCache been made?
func (*Context) AbortWithError ¶
Abort with a status and an error
func (*Context) Decorator ¶
func (c *Context) Decorator() DecoratorFunc
Get the Decorator of the context
func (*Context) FormFile ¶
func (c *Context) FormFile(n string) (*multipart.FileHeader, error)
Get a form file
func (*Context) MultipartForm ¶
Get a multipart form
func (*Context) MustBindWith ¶
Must bind with the given struct
func (*Context) ParamFloat ¶
Get a float value from the params
func (*Context) QueryFloat ¶
Get a float value from the query
func (*Context) RenderBytes ¶
Render a byte array with status
func (*Context) RequestAddress ¶
Get the IP off the requester
func (*Context) SaveFile ¶
func (c *Context) SaveFile(f *multipart.FileHeader, p string) error
Save a file that was uploaded
func (*Context) ShouldBindJSON ¶
Wrapper for ShouldBindWith(a, binding.JSON)
func (*Context) ShouldBindTOML ¶
Wrapper for ShouldBindWith(a, binding.TOML)
func (*Context) ShouldBindWith ¶
Using the provided Binder, binds the context body with the a any
func (*Context) ShouldBindXML ¶
Wrapper for ShouldBindWith(a, binding.XML)
func (*Context) ShouldBindYAML ¶
Wrapper for ShouldBindWith(a, binding.YAML)
type HTML ¶
Default HTML renderer.
func (HTML) WriteContentType ¶
func (h HTML) WriteContentType(w http.ResponseWriter)
Write the content type
type HTMLDebug ¶
type HTMLDebug struct { Files []string Glob string Delims HTMLDelims FuncMap template.FuncMap }
Debug HTML renderer, allows for editing of HTML files at runtime.
type HTMLDelims ¶
Delimiters used in the HTML file, defaults to {{ ... }}
type HTMLRender ¶
type HTMLRender struct { Template *template.Template Delims HTMLDelims }
HTML Renderer implementor
type HTMLRenderer ¶
Interface for Rendering HTML
type HandlerFunc ¶
type HandlerFunc func(c *Context)
HandlerFunc takes a routey.Context pointer
func Wrap ¶
func Wrap(f http.HandlerFunc) HandlerFunc
Wrap a standard http Handler in a routey HandlerFunc
type MiddlewareFunc ¶
type MiddlewareFunc func(c *Context)
Middleware function, run before every request
func (MiddlewareFunc) Serve ¶
func (m MiddlewareFunc) Serve(c *Context)
Serves the middleware function
type Redirect ¶
type Redirect struct {
// contains filtered or unexported fields
}
Redirect struct
func (Redirect) Render ¶
func (r Redirect) Render(w http.ResponseWriter) error
Render the redirect, just sends the requester to the specified location
func (Redirect) WriteContentType ¶
func (r Redirect) WriteContentType(http.ResponseWriter)
Write the content type, there is no content
type Renderer ¶
type Renderer interface { Render(http.ResponseWriter) error WriteContentType(http.ResponseWriter) }
An interface for Rendering in a response
type Route ¶
type Route struct { Path string Params string Method Method HandlerFunc HandlerFunc DecoratorFunc DecoratorFunc // contains filtered or unexported fields }
Route struct
Path: path of the route request
Params: params of the route start with :
Method: method of the route
HandlerFunc: handler function of the route
DecoratorFunc: decorator function of the route
regexp: regexp used for params