Documentation
¶
Index ¶
- Constants
- Variables
- func ExtractClientIP(req *http.Request) (net.IP, error)
- func GetClientIP(r *http.Request) net.IP
- func GetParams(r *http.Request) map[string]string
- func GetStash(r *http.Request) map[string]interface{}
- type Context
- type ResponseWriter
- type Server
- func (s *Server) EnvPrefix() string
- func (s *Server) FastCGI() error
- func (s *Server) GetConf(key string) (val string)
- func (s *Server) Render(w ResponseWriter, r *http.Request)
- func (s *Server) Run() error
- func (s *Server) ServeFiles(path string, root http.FileSystem)
- func (s *Server) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (s *Server) SetEnvPrefix(prefix string)
- type View
Constants ¶
const ( // ConfHTTPBind is the config key for the HTTP bind address ConfHTTPBind = "HTTP_BIND" // ConfHTTPSBind is the config key for the HTTPS bind address ConfHTTPSBind = "HTTPS_BIND" // ConfSSLCert is the config key for the SSL Certificate location ConfSSLCert = "SSL_CERT" // ConfSSLKey is the config key for the SSL Key location ConfSSLKey = "SSL_KEY" // ConfFCGIBind will enable FastCGI mode if set to a bind address ConfFCGIBind = "FASTCGI_BIND" // ConfNoLog will disable logging to stdout ConfNoLog = "NOLOG" // ConfNoCompress will disable opportunistic compression. Useful if you're // behind a reverse proxy that does compression for you. ConfNoCompress = "NOCOMPRESS" )
const ClientIPContextKey = "🍺.userip"
ClientIPContextKey is the key used to fetch the client IP from r.Context()
const ParamsContextKey = 0 // copied from https://github.com/dimfeld/httptreemux/blob/master/context.go#L123
ParamsContextKey is the key used to fetch URL paramaters from r.Context()
const StashContextKey = "🍺.stash"
StashContextKey is the key used to fetch the stash from r.Context()
const Timeout = 10 * time.Second
Timeout defines the default time to wait before killing active connections on shutdown or restart.
const ViewContextKey = "🍺.view"
ViewContextKey is the key used to fetch the view from r.Context()
Variables ¶
var BufPoolAlloc = 10 * 1024
BufPoolAlloc is the maximum size of each buffer.
var BufPoolSize = 32
BufPoolSize is the size of the BufferPool.
Functions ¶
func ExtractClientIP ¶
ExtractClientIP parses the request and returns the clients IP
func GetClientIP ¶
GetClientIP fetches the parsed client IP from an http.Request
Types ¶
type Context ¶
type Context interface {
Deadline() (time.Time, bool)
Done() <-chan struct{}
Err() error
Value(interface{}) interface{}
}
Context is a clone of the context.Context interface, for convenience
type ResponseWriter ¶
type ResponseWriter interface {
Header() http.Header
Write([]byte) (int, error)
WriteHeader(int)
Written() bool
}
ResponseWriter is Ale's custom version of http.ResponseWriter
type Server ¶
type Server struct {
// Timeout is the duration to wait before killing active requests when stopping the server
Timeout time.Duration
// Context is the master context for this server instance
Context Context
// TemplateDir is the name of the path which contains the HTML templates.
// If this path contains a subdir 'lib/', any files contianed within lib
// are also loaded into each template. This is where shared components
// should generally go.
TemplateDir string
// View is the default View configuration
View *View
Router *httptreemux.ContextGroup
// contains filtered or unexported fields
}
Server represents an Ale server instance.
func (*Server) Render ¶
func (s *Server) Render(w ResponseWriter, r *http.Request)
Render renders the page
func (*Server) ServeFiles ¶
func (s *Server) ServeFiles(path string, root http.FileSystem)
ServeFiles is a wrapper around httprouter.ServeFiles
func (*Server) SetEnvPrefix ¶
SetEnvPrefix sets the environment prefix for configuration