handlers

package
v0.0.0-...-2ec3f48 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: ISC Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ArcGISInfoRoot = ArcGISRoot + "info"
View Source
const ArcGISRoot = "/arcgis/rest/"
View Source
const ArcGISServicesRoot = ArcGISRoot + "services/"

Variables

This section is empty.

Functions

func BlankPNG

func BlankPNG(tilesize uint32) []byte

BlankPNG returns bytes of a blank PNG of the requested size, falling back to 256px if a suitable size is not available. Used for the request handlers to return when an image tile is not available. Images created with https://png-pixel.com/ then minified using tinypng.com

func RelativePathID

func RelativePathID(filename, baseDir string) (string, error)

RelativePathID returns a relative path from the basedir to the filename.

func SHA1ID

func SHA1ID(filename string) string

SHA1ID generates a URL safe base64 encoded SHA1 hash of the filename.

Types

type HandlerWrapper

type HandlerWrapper func(http.Handler) http.Handler

HandlerWrapper is a type definition for a function that takes an http.Handler and returns an http.Handler

func HMACAuthMiddleware

func HMACAuthMiddleware(secretKey string, serviceSet *ServiceSet) HandlerWrapper

HMACAuthMiddleware wraps incoming requests to enforce HMAC signature authorization. All requests are expected to have either "signature" and "date" query parameters or "X-Signature" and "X-Signature-Date" headers.

type IDGenerator

type IDGenerator func(filename, baseDir string) (string, error)

type ServiceInfo

type ServiceInfo struct {
	ImageType string `json:"imageType"`
	URL       string `json:"url"`
	Name      string `json:"name"`
}

ServiceInfo provides basic information about the service.

type ServiceSet

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

ServiceSet is a group of tilesets plus configuration options. It provides access to all tilesets from a root URL.

func New

func New(cfg *ServiceSetConfig) (*ServiceSet, error)

New returns a new ServiceSet. If no ServiceSetConfig is provided, the service is initialized with default values of ServiceSetConfig.

func (*ServiceSet) AddTileset

func (s *ServiceSet) AddTileset(filename, id string) error

AddTileset adds a single tileset identified by idGenerator using the filename. If a service already exists with that ID, an error is returned.

func (*ServiceSet) Handler

func (s *ServiceSet) Handler() http.Handler

Handler returns a http.Handler that serves the endpoints of the ServiceSet. The function ef is called with any occurring error if it is non-nil, so it can be used for e.g. logging with logging facilities of the caller.

func (*ServiceSet) HasTileset

func (s *ServiceSet) HasTileset(id string) bool

HasTileset returns true if the tileset identified by id exists within this ServiceSet.

func (*ServiceSet) IDFromURLPath

func (s *ServiceSet) IDFromURLPath(id string) string

IDFromURLPath extracts a tileset ID from a URL Path. If no valid ID is found, a blank string is returned.

func (*ServiceSet) LockTileset

func (s *ServiceSet) LockTileset(id string)

LockTileset sets a write mutex on the tileset to block reads while this tileset is being updated. This is ignored if the tileset does not exist.

func (*ServiceSet) RemoveTileset

func (s *ServiceSet) RemoveTileset(id string) error

RemoveTileset removes the Tileset and closes the associated mbtiles file identified by id, if it already exists. If it does not exist, this returns without error. Any errors encountered removing the Tileset are returned.

func (*ServiceSet) Size

func (s *ServiceSet) Size() int

Size returns the number of tilesets in this ServiceSet

func (*ServiceSet) UnlockTileset

func (s *ServiceSet) UnlockTileset(id string)

UnlockTileset removes the write mutex on the tileset. This is ignored if the tileset does not exist.

func (*ServiceSet) UpdateTileset

func (s *ServiceSet) UpdateTileset(id string) error

UpdateTileset reloads the Tileset identified by id, if it already exists. Otherwise, this returns an error. Any errors encountered updating the Tileset are returned.

type ServiceSetConfig

type ServiceSetConfig struct {
	EnableServiceList bool
	EnableTileJSON    bool
	EnablePreview     bool
	EnableArcGIS      bool
	RootURL           *url.URL
	ErrorWriter       io.Writer
}

ServiceSetConfig provides configuration options for a ServiceSet

type Tileset

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

Tileset provides a tileset constructed from an mbtiles file

func (*Tileset) TileJSON

func (ts *Tileset) TileJSON(svcURL string, query string) (map[string]interface{}, error)

TileJSON returns the TileJSON (as a map of strings to interface{} values) for the tileset. This can be rendered into templates or returned via a handler.

Jump to

Keyboard shortcuts

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