Documentation ¶
Overview ¶
Package srest contains tools for REST services and web sites.
Copyright 2016 The SREST Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- Variables
- func Bind(vars url.Values, dst interface{}) error
- func Debug(ok bool)
- func JSON(w http.ResponseWriter, v interface{}) error
- func LoadViews(dirs string, funcMap template.FuncMap) error
- func Render(w http.ResponseWriter, name string, v interface{}) error
- func Static(uri, dir string) http.Handler
- type ByURIDesc
- type Modeler
- type Options
- type RESTfuler
- type SREST
- func (m *SREST) Del(uri string, hf http.Handler, mws ...func(http.Handler) http.Handler)
- func (m *SREST) Get(uri string, hf http.Handler, mws ...func(http.Handler) http.Handler)
- func (m *SREST) Post(uri string, hf http.Handler, mws ...func(http.Handler) http.Handler)
- func (m *SREST) Put(uri string, hf http.Handler, mws ...func(http.Handler) http.Handler)
- func (m *SREST) Run(port int) chan os.Signal
- func (m *SREST) Use(uri string, n RESTfuler, mws ...func(http.Handler) http.Handler)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultFuncMap can be used with LoadViews for common template tasks like: // cap: capitalize strings // eqs: compare value of two types. DefaultFuncMap = deffuncmap() )
View Source
var ( // ErrImplementsModeler error returned when modeler interface is not implemented. ErrImplementsModeler = errors.New("srest: modeler interface not found") )
View Source
var ( // ErrTemplateNotFound error returned when template is not found. ErrTemplateNotFound = errors.New("srest: template not found") )
Functions ¶
Types ¶
type ByURIDesc ¶ added in v0.2.0
type ByURIDesc []tmpHandler
ByURIDesc implements sort.Interface for []tmpHandler based on the URI field.
type RESTfuler ¶
type RESTfuler interface { Create(w http.ResponseWriter, r *http.Request) One(w http.ResponseWriter, r *http.Request) List(w http.ResponseWriter, r *http.Request) Update(w http.ResponseWriter, r *http.Request) Delete(w http.ResponseWriter, r *http.Request) }
RESTfuler interface.
type SREST ¶
type SREST struct { Mux *mux.Router Options *Options Map map[string]bool // contains filtered or unexported fields }
SREST type.
func (*SREST) Get ¶
Get wrapper register a GET endpoint with optional middlewares. It will generate endpoints for `uri` and `uri/` because some pat unexpected behaviour.
Click to show internal directories.
Click to hide internal directories.