Documentation ¶
Overview ¶
Speedy aims to be a Go wrapper around standard net.HTTP implementations to provide seamless integration and helpful utilities.
It is NOT a total framework, and instead is a lightweight adapter on existing tooling.
Index ¶
- func WrapHandler(handler Handler) http.HandlerFunc
- type Conn
- type Handler
- type Muxer
- func (m *Muxer) Add(path string, handlers ...Handler) *Route
- func (m Muxer) BuildServeMux() *http.ServeMux
- func (m *Muxer) Delete(pattern string, handler Handler)
- func (m *Muxer) Get(path string, handler Handler)
- func (m *Muxer) Handle(path string, handler Handler)
- func (m *Muxer) Post(pattern string, handler Handler)
- func (m *Muxer) Put(pattern string, handler Handler)
- func (m *Muxer) Use(handler Handler)
- type Route
- func (r Route) AbsPath() string
- func (r *Route) AddChild(path string, handlers ...Handler) *Route
- func (r *Route) AddMethod(method string, handler Handler) *Route
- func (r *Route) AddMiddleware(handler Handler) *Route
- func (r *Route) AddMiddlewareAfter(handler Handler) *Route
- func (r *Route) Delete(handler Handler) *Route
- func (r *Route) Get(handler Handler) *Route
- func (r *Route) Post(handler Handler) *Route
- func (r *Route) Put(handler Handler) *Route
- func (r *Route) SetHandler(handler Handler) *Route
- func (r *Route) SetMethod(method string) *Route
- func (r *Route) SetPath(path string) *Route
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WrapHandler ¶
func WrapHandler(handler Handler) http.HandlerFunc
WrapHandler takes a speedy.Handler and converts it for use with http.HandlerFunc.
Types ¶
type Conn ¶
type Conn struct { }
Conn is used to provide a combined handler experience simplifying the process of handling connections
func NewConn ¶
func NewConn(w http.ResponseWriter, r *http.Request) *Conn
NewConn wraps a standard http.HandlerFunc parameters into a new connection.
type Handler ¶
Handler is the type of function that can respond to a HTTP request. It is provided a combined struct of Conn which contains the request and response objects.
type Muxer ¶
type Muxer struct {
// contains filtered or unexported fields
}
Muxer is an extension on the http.ServeMux that handles routes. The final http.ServeMux can be built during runtime.
func (Muxer) BuildServeMux ¶
func (*Muxer) Delete ¶
Delete binds an endpoint handler for a pattern path limited to a DELETE method.
func (*Muxer) Handle ¶
Handle binds an endpoint handler for a pattern path with no method limitations.
Note that this will be called last in the event that another method specific request is present as that handler is considered "more specific".
type Route ¶
type Route struct { Method string Path string MiddlewareBefore []Handler MiddlewareAfter []Handler Parent *Route Children []*Route Handler Handler }
func (*Route) AddMiddleware ¶
func (*Route) AddMiddlewareAfter ¶
func (*Route) SetHandler ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds the main data for starting up a web HTTP server.
func NewServer ¶
NewServer constructs a new Server pointer for use and sets the host and port parameters.
func (*Server) BuildMux ¶
func (s *Server) BuildMux()
BuildMux assembles the final runtime http.ServeMux that will handle the requests setup for binding. This is called automatically by the [ListenAndServe] method, but is provided in case you need to rebuild it.
func (*Server) HTTP2Server ¶
HTTP2Server returns the underlying http2.Server pointer. This object is only used in HTTP2 clear-text mode and not during TLS operation.
func (*Server) HTTPServer ¶
HTTPServer returns the underlying http.Server pointer.
func (*Server) ListenAndServe ¶
ListenAndServe opens and starts listening on the server address for incoming requests. If there is a TLS certificate and key filepath set, it will use TLS. Otherwise it will use basic HTTP.
func (*Server) ServeMux ¶
ServeMux returns the underlying http.ServeMux pointer.