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 ErrMalformedTileTemplateURL
- type HandleCapabilities
- type HandleMapCapabilities
- type HandleMapLayerZXY
- type HandleMapStyle
- type TileURLTemplate
Constants ¶
const ( // MaxTileSize is 500k. Currently, just throws a warning when tile // is larger than MaxTileSize MaxTileSize = 500000 // QueryKeyDebug is a common query string key used throughout the pacakge // the value should always be a boolean QueryKeyDebug = "debug" )
const ( TileURLMapsToken = "maps" TileURLZToken = "{z}" TileURLXToken = "{x}" TileURLYToken = "{y}" TileURLFileFormat = "pbf" )
const (
HeaderXForwardedProto = "X-Forwarded-Proto"
)
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 *url.URL // 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 = "/" // ProxyProtocol is a custom protocol that will be used to generate the URLs // included in the capabilities endpoint responses. This is useful when he // server sits behind a reverse proxy // (See https://github.com/go-spatial/tegola/pull/967) ProxyProtocol string // 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 { return &url.URL{ Scheme: scheme(r), Host: hostName(r).Host, } }
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 ¶ added in v0.8.0
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 ¶ added in v0.8.0
HeadersHandler is middleware for adding user defined response headers
func NewRouter ¶ added in v0.7.0
func NewRouter(a *atlas.Atlas) *httptreemux.TreeMux
NewRouter set's up our routes.
Types ¶
type Capabilities ¶ added in v0.3.0
type Capabilities struct { Version string `json:"version"` Maps []CapabilitiesMap `json:"maps"` }
type CapabilitiesLayer ¶ added in v0.3.0
type CapabilitiesLayer struct { Name string `json:"name"` Tiles []TileURLTemplate `json:"tiles"` MinZoom uint `json:"minzoom"` MaxZoom uint `json:"maxzoom"` }
type CapabilitiesMap ¶ added in v0.3.0
type CapabilitiesMap struct { Name string `json:"name"` Attribution string `json:"attribution"` Bounds *geom.Extent `json:"bounds"` Center [3]float64 `json:"center"` Tiles []TileURLTemplate `json:"tiles"` Capabilities string `json:"capabilities"` Layers []CapabilitiesLayer `json:"layers"` }
type ErrMalformedTileTemplateURL ¶ added in v0.21.0
type ErrMalformedTileTemplateURL struct {
Got string
}
func (ErrMalformedTileTemplateURL) Error ¶ added in v0.21.0
func (e ErrMalformedTileTemplateURL) Error() string
type HandleCapabilities ¶ added in v0.3.0
type HandleCapabilities struct{}
func (HandleCapabilities) ServeHTTP ¶ added in v0.3.0
func (req HandleCapabilities) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HandleMapCapabilities ¶ added in v0.3.1
type HandleMapCapabilities struct {
// contains filtered or unexported fields
}
func (HandleMapCapabilities) ServeHTTP ¶ added in v0.3.1
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 ¶ added in v0.3.1
type HandleMapLayerZXY struct { // the Atlas to use, nil (default) is the default atlas Atlas *atlas.Atlas // contains filtered or unexported fields }
func (HandleMapLayerZXY) ServeHTTP ¶ added in v0.3.1
func (req HandleMapLayerZXY) ServeHTTP(w http.ResponseWriter, r *http.Request)
URI scheme: /maps/:map_name/:layer_name/:z/:x/:y?param=value 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
param - configurable query parameters and their values
type HandleMapStyle ¶ added in v0.4.0
type HandleMapStyle struct {
// contains filtered or unexported fields
}
func (HandleMapStyle) ServeHTTP ¶ added in v0.4.0
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
type TileURLTemplate ¶ added in v0.21.0
type TileURLTemplate struct { Scheme string Host string PathPrefix string Query url.Values MapName string LayerName string }
TileURLTemplate is responsible for forming up tile URLs which contain the uri template variables {z}, {x} and {y}.pbf as the suffix of the path.
func (*TileURLTemplate) MarshalJSON ¶ added in v0.21.0
func (t *TileURLTemplate) MarshalJSON() ([]byte, error)
func (TileURLTemplate) Path ¶ added in v0.21.0
func (t TileURLTemplate) Path() string
Path will build the path part of the URI, including the template variables {z}, {x} and {y}.pbf. The path will start with a forward slash ("/").
func (TileURLTemplate) String ¶ added in v0.21.0
func (t TileURLTemplate) String() string
func (*TileURLTemplate) UnmarshalJSON ¶ added in v0.21.0
func (t *TileURLTemplate) UnmarshalJSON(data []byte) error