Back to godoc.org

Package server

v0.0.0-...-60453eb
Latest Go to latest

The latest major version is .

Published: Sep 12, 2020 | License: MIT | Module: gitee.com/exlimit/tegola

Overview

Package server implements the http frontend

Index

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.

func GZipHandler

func GZipHandler(next http.Handler) http.Handler

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

func HeadersHandler(next http.Handler) http.Handler

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.

func Start

func Start(a *atlas.Atlas, port string) *http.Server

Start starts the tile server binding to the provided port

func TileCacheHandler

func TileCacheHandler(a *atlas.Atlas, 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)

type Capabilities

type Capabilities struct {
	Version string            `json:"version"`
	Maps    []CapabilitiesMap `json:"maps"`
}

type CapabilitiesLayer

type CapabilitiesLayer struct {
	Name    string   `json:"name"`
	Tiles   []string `json:"tiles"`
	MinZoom uint     `json:"minzoom"`
	MaxZoom uint     `json:"maxzoom"`
}

type CapabilitiesMap

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

type FilePathPrefixStripper

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

func (*FilePathPrefixStripper) Open

func (fsps *FilePathPrefixStripper) Open(name string) (http.File, error)

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier