server

package
v0.6.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2018 License: MIT Imports: 20 Imported by: 0

README

Sever

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"
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.
  • cors_allowed_origin (string): [Optional] The value to include with the Cross Origin Resource Sharing (CORS) Access-Control-Allow-Origin header. Defaults to *.

Local development of the embedded viewer

Tegola's built in viewer code is stored in the static/ directory. In order to embed the static files into the tegola binary the package go-bindata is used. Once go-bindata is installed the following command can be used to generate a .go file for inclusion in the tegola binary:

go-bindata -pkg=bindata -o=bindata/bindata.go -ignore=.DS_Store static/...

go-bindata also supports a debug mode which is descried as "Do not embed the assets, but provide the embedding API. Contents will still be loaded from disk." This mode is ideal for development and can be configured using the following command:

go-bindata -debug -pkg=bindata -o=bindata/bindata.go -ignore=.DS_Store static/...

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"

Documentation

Overview

Package server implements the http frontend

Index

Constants

View Source
const (
	//	MaxTileSize is 500k. Currently just throws a warning when tile
	//	is larger than MaxTileSize
	MaxTileSize = 500000
)

Variables

View Source
var (
	//	set at runtime from main
	Version string
	//	configurable via the tegola config.toml file (set in main.go)
	HostName string
	//	configurable via the tegola config.toml file (set in main.go)
	Port string
	//	the "Access-Control-Allow-Origin" CORS header.
	//	configurable via the tegola config.toml file (set in main.go)
	CORSAllowedOrigin = "*"
	//	reference to the version of atlas to work with
	Atlas *atlas.Atlas
	//	tile buffer to use. can be overwritten in the config file
	TileBuffer float64 = tegola.DefaultTileBuffer
)

Functions

func CORSHandler added in v0.6.0

func CORSHandler(next http.Handler) http.Handler

func Start

func Start(port string) *http.Server

Start starts the tile server binding to the provided port

func TileCacheHandler added in v0.4.0

func TileCacheHandler(next http.Handler) http.Handler

TileCacheHandler implements a request cache for tiles on requests when the URLs have a /:z/:x/:y scheme suffix (i.e. /osm/1/3/4.pbf)

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   []string `json:"tiles"`
	MinZoom int      `json:"minzoom"`
	MaxZoom int      `json:"maxzoom"`
}

type CapabilitiesMap added in v0.3.0

type CapabilitiesMap struct {
	Name         string              `json:"name"`
	Attribution  string              `json:"attribution"`
	Bounds       [4]float64          `json:"bounds"`
	Center       [3]float64          `json:"center"`
	Tiles        []string            `json:"tiles"`
	Capabilities string              `json:"capabilities"`
	Layers       []CapabilitiesLayer `json:"layers"`
}

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)

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 {
	// 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 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 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 HandleMapZXY added in v0.3.1

type HandleMapZXY struct {
	// contains filtered or unexported fields
}

func (HandleMapZXY) ServeHTTP added in v0.3.1

func (req HandleMapZXY) ServeHTTP(w http.ResponseWriter, r *http.Request)

URI scheme: /maps/:map_name/:z/:x/:y map_name - map name in the config file z, x, y - tile coordinates as described in the Slippy Map Tilenames specification

z - zoom level
x - row
y - column

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL