# README
Server
The server package is responsible for handling webserver requests for map tiles and various JSON endpoints describing the configured server. Example config:
[webserver]
port = ":9090" # set something different than default ":8080"
ssl_cert = "fullchain.pem" # ssl cert for serving by https
ssl_key = "privkey.pem" # ssl key for serving by https
[webserver.headers]
Access-Control-Allow-Origin = "*"
Config properties
port
(string): [Optional] Port and bind string. For example ":9090" or "127.0.0.1:9090". Defaults to ":8080"hostname
(string): [Optional] The hostname to use in the various JSON endpoints. This is useful if tegola is behind a proxy and can't read the API consumer's request host directly.uri_prefix
(string): [Optional] A prefix to add to all API routes. This is useful when tegola is behind a proxy (i.e. example.com/tegola). The prexfix will be added to all URLs included in the capabilities endpoint responses.ssl_cert
(string): [Optional, unless ssl_key provided] Path to a certificate file for serving through HTTPSssl_key
(string): [Optional, unless ssl_cert provided] Path to a private key file for serving through HTTPS
Local development of the embedded viewer
Tegola's built in viewer code is stored in the ui/
directory. To build the ui npm
must be installed. Once npm
is installed the following command can be run from the repository root to generate a .go file for inclusion in the tegola binary:
go generate ./server
Disabling the viewer
The viewer can be excluded during building by using the build flag noViewer
. For example, building tegola from the cmd/tegola
directory:
go build -tags "noViewer"
# Functions
GZipHandler is responsible for determining if the incoming request should be served gzipped data.
HeadersHandler is middleware for adding user defined response headers.
NewRouter set's up our routes.
Start starts the tile server binding to the provided port.
TileCacheHandler implements a request cache for tiles on requests when the URLs have a /:z/:x/:y scheme suffix (i.e.
# Constants
MaxTileSize is 500k.
QueryKeyDebug is a common query string key used throughout the pacakge the value should always be a boolean.
# Variables
DefaultCORSHeaders define the default CORS response headers added to all requests.
Headers is the map of user defined response headers.
HostName is the name of the host to use for construction of URLS.
Port is the port the server is listening on, used for construction of URLS.
ProxyProtocol is a custom protocol that will be used to generate the URLs included in the capabilities endpoint responses.
SSLCert is a filepath to an SSL cert, this will be used to enable https.
SSLKey is a filepath to an SSL key, this will be used to enable https.
URIPrefix sets a prefix on all server endpoints.
URLRoot builds a string containing the scheme, host and port based on a combination of user defined values, headers and request parameters.
Version is the version of the software, this should be set by the main program, before starting up.
# Structs
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.