Documentation ¶
Overview ¶
Package server implements the http frontend
Index ¶
- Constants
- Variables
- func GZipHandler(next http.Handler) http.Handler
- func HeadersHandler(next http.Handler) http.Handler
- func NewRouter(a *atlas.Atlas) *httptreemux.TreeMux
- func Start(a *atlas.Atlas, port string) *http.Server
- func TileCacheHandler(a *atlas.Atlas, next http.Handler) http.Handler
- type Capabilities
- type CapabilitiesLayer
- type CapabilitiesMap
- type FilePathPrefixStripper
- type HandleCapabilities
- type HandleMapCapabilities
- type HandleMapLayerZXY
- type HandleMapStyle
Constants ¶
const ( // MaxTileSize is 500k. Currently just throws a warning when tile // is larger than MaxTileSize MaxTileSize = 500000 )
Variables ¶
var ( // Version is the version of the software, this should be set by the main program, before starting up. // It is used by various Middleware to determine the version. Version string = "Version Not Set" // HostName is the name of the host to use for construction of URLS. // configurable via the tegola config.toml file (set in main.go) HostName string // Port is the port the server is listening on, used for construction of URLS. // configurable via the tegola config.toml file (set in main.go) Port string // SSLCert is a filepath to an SSL cert, this will be used to enable https SSLCert string // SSLKey is a filepath to an SSL key, this will be used to enable https SSLKey string // Headers is the map of user defined response headers. // configurable via the tegola config.toml file (set in main.go) Headers = map[string]string{} // URIPrefix sets a prefix on all server endpoints. This is often used // when the server sits behind a reverse proxy with a prefix (i.e. /tegola) URIPrefix = "/" // DefaultCORSHeaders define the default CORS response headers added to all requests DefaultCORSHeaders = map[string]string{ "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, OPTIONS", } )
var URLRoot = func(r *http.Request) *url.URL { root := url.URL{ Scheme: scheme(r), Host: hostName(r), } return &root }
URLRoot builds a string containing the scheme, host and port based on a combination of user defined values, headers and request parameters. The function is public so it can be overridden for other implementations.
Functions ¶
func GZipHandler ¶
GZipHandler is responsible for determining if the incoming request should be served gzipped data. All response data is assumed to be compressed prior to being passed to this handler.
If the incoming request has the "Accept-Encoding" header set with the values of "gzip" or "*" the response header "Content-Encoding: gzip" is set and the compressed data is returned.
If no "Accept-Encoding" header is present or "Accept-Encoding" has a value of "gzip;q=0" or "*;q=0" the response is decompressed prior to being sent to the client.
func HeadersHandler ¶
HeadersHandler is middleware for adding user defined response headers
func NewRouter ¶
func NewRouter(a *atlas.Atlas) *httptreemux.TreeMux
NewRouter set's up the our routes.
Types ¶
type Capabilities ¶
type Capabilities struct { Version string `json:"version"` Maps []CapabilitiesMap `json:"maps"` }
type CapabilitiesLayer ¶
type CapabilitiesMap ¶
type FilePathPrefixStripper ¶
type FilePathPrefixStripper struct {
// contains filtered or unexported fields
}
type HandleCapabilities ¶
type HandleCapabilities struct{}
func (HandleCapabilities) ServeHTTP ¶
func (req HandleCapabilities) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HandleMapCapabilities ¶
type HandleMapCapabilities struct {
// contains filtered or unexported fields
}
func (HandleMapCapabilities) ServeHTTP ¶
func (req HandleMapCapabilities) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP returns details about a map according to the tileJSON spec (https://github.com/mapbox/tilejson-spec/tree/master/2.1.0)
URI scheme: /capabilities/:map_name.json map_name - map name in the config file
type HandleMapLayerZXY ¶
type HandleMapLayerZXY struct { // the Atlas to use, nil (default) is the default atlas Atlas *atlas.Atlas // contains filtered or unexported fields }
func (HandleMapLayerZXY) ServeHTTP ¶
func (req HandleMapLayerZXY) ServeHTTP(w http.ResponseWriter, r *http.Request)
URI scheme: /maps/:map_name/:layer_name/:z/:x/:y map_name - map name in the config file layer_name - name of the single map layer to render z, x, y - tile coordinates as described in the Slippy Map Tilenames specification
z - zoom level x - row y - column
type HandleMapStyle ¶
type HandleMapStyle struct {
// contains filtered or unexported fields
}
func (HandleMapStyle) ServeHTTP ¶
func (req HandleMapStyle) ServeHTTP(w http.ResponseWriter, r *http.Request)
returns details about a map according to the tileJSON spec (https://github.com/mapbox/tilejson-spec/tree/master/2.1.0)
URI scheme: /capabilities/:map_name.json
map_name - map name in the config file