Documentation
¶
Overview ¶
Package rum implements an HTTP server.
Index ¶
- Variables
- func ListenAndServe(addr string, handler http.Handler) error
- func ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handler) error
- func Recovery(w http.ResponseWriter, r *http.Request)
- type Entry
- func (entry *Entry) All()
- func (entry *Entry) CONNECT() *Entry
- func (entry *Entry) DELETE() *Entry
- func (entry *Entry) GET() *Entry
- func (entry *Entry) HEAD() *Entry
- func (entry *Entry) OPTIONS() *Entry
- func (entry *Entry) PATCH() *Entry
- func (entry *Entry) POST() *Entry
- func (entry *Entry) PUT() *Entry
- func (entry *Entry) TRACE() *Entry
- type Mux
- func (m *Mux) Group(group string, f func(m *Mux))
- func (m *Mux) Handle(pattern string, handler http.Handler) *Entry
- func (m *Mux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request)) *Entry
- func (m *Mux) NotFound(handler http.HandlerFunc)
- func (m *Mux) Params(r *http.Request) map[string]string
- func (m *Mux) Recovery(handler http.HandlerFunc)
- func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (m *Mux) Use(handler http.HandlerFunc)
- type Rum
- func (m *Rum) Close() error
- func (m *Rum) Run(addr string) error
- func (m *Rum) RunTLS(addr string, certFile, keyFile string) error
- func (m *Rum) Serve(l net.Listener) error
- func (m *Rum) ServeTLS(l net.Listener, certFile, keyFile string) error
- func (m *Rum) SetFast(fast bool)
- func (m *Rum) SetPoll(poll bool)
Constants ¶
This section is empty.
Variables ¶
var DefaultServer = New()
DefaultServer is the default HTTP server.
var ErrGroupExisted = errors.New("Group Existed")
ErrGroupExisted is the error returned by Group when registers a existed group.
var ErrParamsKeyEmpty = errors.New("Params key must be not empty")
ErrParamsKeyEmpty is the error returned by HandleFunc when the params key is empty.
var RecoveryContextKey = &contextKey{"recovery"}
RecoveryContextKey is a context key.
Functions ¶
func ListenAndServe ¶
ListenAndServe listens on the TCP network address addr and then calls Serve with handler to handle requests on incoming connections. Accepted connections are configured to enable TCP keep-alives.
The handler is typically nil, in which case the DefaultServeMux is used.
ListenAndServe always returns a non-nil error.
func ListenAndServeTLS ¶
ListenAndServeTLS acts identically to ListenAndServe, except that it expects HTTPS connections. Additionally, files containing a certificate and matching private key for the server must be provided. If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any intermediates, and the CA's certificate.
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry represents an HTTP HandlerFunc entry.
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux is an HTTP request multiplexer.
func (*Mux) HandleFunc ¶
HandleFunc registers a handler function with the given pattern to the Mux.
func (*Mux) NotFound ¶
func (m *Mux) NotFound(handler http.HandlerFunc)
NotFound registers a not found handler function to the Mux.
func (*Mux) Recovery ¶ added in v0.0.2
func (m *Mux) Recovery(handler http.HandlerFunc)
Recovery registers a recovery handler function to the Mux.
type Rum ¶
type Rum struct {
*Mux
Handler http.Handler
// TLSConfig optionally provides a TLS configuration for use
// by ServeTLS and ListenAndServeTLS. Note that this value is
// cloned by ServeTLS and ListenAndServeTLS, so it's not
// possible to modify the configuration with methods like
// tls.Config.SetSessionTicketKeys. To use
// SetSessionTicketKeys, use Server.Serve with a TLS Listener
// instead.
TLSConfig *tls.Config
// contains filtered or unexported fields
}
Rum is an HTTP server.
func (*Rum) Run ¶
Run listens on the TCP network address addr and then calls Serve with m to handle requests on incoming connections. Accepted connections are configured to enable TCP keep-alives.
Run always returns a non-nil error.
func (*Rum) Serve ¶
Serve accepts incoming connections on the Listener l, creating a new service goroutine for each, or registering the conn fd to poll that will trigger the fd to read requests and then call handler to reply to them.
func (*Rum) ServeTLS ¶
ServeTLS accepts incoming connections on the Listener l, creating a new service goroutine for each. The service goroutines perform TLS setup and then read requests, calling srv.Handler to reply to them.
Files containing a certificate and matching private key for the server must be provided if neither the Server's TLSConfig.Certificates nor TLSConfig.GetCertificate are populated. If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any intermediates, and the CA's certificate.
ServeTLS always returns a non-nil error. After Shutdown or Close, the returned error is ErrServerClosed.

