Documentation
¶
Overview ¶
Package dingo is a simple wrapper around net/http providing very simple routing, with RegEx patterns, and views (templates).
Index ¶
- Constants
- func HTTPListener(ip string, port int) (net.Listener, error)
- func IsCanonical(p string) (string, bool)
- func SOCKListener(sockFile string, mode os.FileMode) (net.Listener, error)
- func TLSListener(ip string, port int, certFile, keyFile string) (net.Listener, error)
- type Context
- type Error
- type Handler
- type NewIRoute
- type Route
- type Router
- func (r Router) Connect(h interface{}) Router
- func (r Router) Delete(h interface{}) Router
- func (r Router) Get(h interface{}) Router
- func (r Router) Options(h interface{}) Router
- func (r Router) Post(h interface{}) Router
- func (r Router) Put(h interface{}) Router
- func (r Router) Trace(h interface{}) Router
- type Routes
- type Server
- func (s *Server) RRoute(path string, handler interface{}, methods ...string)
- func (s *Server) RRouter(p string) Router
- func (s *Server) ReRoute(path string, handler Handler, methods ...string)
- func (s *Server) ReRouter(p string) Router
- func (s *Server) Route(rt Route, methods ...string)
- func (s *Server) SRoute(path string, handler Handler, methods ...string)
- func (s *Server) SRouter(p string) Router
- func (s *Server) Serve()
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
Constants ¶
const (
VERSION string = "0.1.15"
)
Variables ¶
This section is empty.
Functions ¶
func HTTPListener ¶
HTTPListener returns a new net.Listener for the given ip/port
func IsCanonical ¶
IsCanonical returns wether the given path is canonical.
func SOCKListener ¶
SOCKListener returns a new unix sock listener.
Types ¶
type Context ¶
Context holds both the request and response objects, along with route-data, and is passed to handlers.
func NewContext ¶
func NewContext(response http.ResponseWriter, request *http.Request) Context
NewContext creates, and returns, a new Context
func (*Context) HttpError ¶
HttpError issues the given http error (status) and writes any provided msgs. The ErrorHandler is invoked when it has been set and there are no provided msgs.
func (*Context) RedirectPerm ¶
RedirectPerm issues a permanent redirect to the response.
type Error ¶
Error func is a handler type called when there is a panic.
var ErrorHandler Error
ErrorHandler is the actual handler invoked upon panic.
type Handler ¶
type Handler func(ctx Context)
Handler is a func type called when a matching route is found.
type Route ¶
type Route interface { Path() string IsCanonical() bool Matches(path string) bool Execute(ctx Context) }
Route is the handling object when a request matches.
func NewReRoute ¶
NewReRoute returns a new RegEx route for the given path/handler.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements http.Handler and routes calls to handlers view a Routes collection.
func (*Server) RRoute ¶
RRoute adds a new RegEx route where the params are passed as params to the given handler.
func (*Server) RRouter ¶
SRouter returns a new Router used to add RegEx routes to the server where the params are passed to the handler.