Documentation
¶
Overview ¶
Copyright 2024 Michael Davis
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2024 Michael Davis ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func AllowedLayersFromContext(ctx context.Context) (*[]string, bool)
- func BackgroundContext() context.Context
- func CachedFromContext(ctx context.Context) (*bool, bool)
- func CopyAuthRestrictions(from, to context.Context)
- func LayerPatternMatchesFromContext(ctx context.Context) (*map[string]string, bool)
- func LimitAreaPartialFromContext(ctx context.Context) (*bool, bool)
- func LimitLayersFromContext(ctx context.Context) (*bool, bool)
- func NewRequestContext(req *http.Request) context.Context
- func RefDepthFromContext(ctx context.Context) (*int, bool)
- func ReqFromContext(ctx context.Context) (*http.Request, bool)
- func SetIdentity(ctx context.Context, userID, tenantID string)
- func StartTimeFromContext(ctx context.Context) (time.Time, bool)
- func TenantIDFromContext(ctx context.Context) (*string, bool)
- func UserIDFromContext(ctx context.Context) (*string, bool)
- type Bounds
- func (b Bounds) BufferRelative(pct float64) Bounds
- func (b Bounds) Centroid() (float64, float64)
- func (b Bounds) ConfineToPsuedoMercatorRange() Bounds
- func (b Bounds) Contains(b2 Bounds) bool
- func (b Bounds) ContainsPoint(x float64, y float64) bool
- func (b Bounds) ConvertToPsuedoMercatorRange() Bounds
- func (b Bounds) Height() float64
- func (b Bounds) IntersectionWith(b2 Bounds) Bounds
- func (b Bounds) Intersects(b2 Bounds) bool
- func (b Bounds) IsNullIsland() bool
- func (b Bounds) ToConfig() config.BoundsConfig
- func (b Bounds) ToEWKT() string
- func (b Bounds) ToWKT() string
- func (b Bounds) Width() float64
- type Image
- type InvalidArgumentError
- type InvalidContentLengthError
- type InvalidContentTypeError
- type InvalidSridError
- type ProviderAuthError
- type RangeError
- type RemoteConnectionError
- type RemoteServerError
- type TileRequest
- func (t TileRequest) GetBounds() (*Bounds, error)
- func (t TileRequest) GetBoundsProjection(srid uint) (*Bounds, error)
- func (t TileRequest) IntersectsBounds(b Bounds) (bool, error)
- func (t TileRequest) IntersectsBoundsProjection(b Bounds, srid uint) (bool, error)
- func (t TileRequest) String() string
- func (t TileRequest) StringWithSeparator(sep string) string
- type TimeoutError
- type TypeOfError
- type TypedError
- type UnauthorizedError
Constants ¶
const ( // Bad geographic extent or tile coordinates. Generally a 400 TypeOfErrorBounds = iota // Incoming auth, not outgoing. Generally a 401 TypeOfErrorAuth // A provider misbehaved, maybe because its upstream is down. Generally a 500 TypeOfErrorProvider // Problems with the request besides bounds TypeOfErrorBadRequest // Usually a real problem the operator needs to know about. Generally a 500 TypeOfErrorOther // Exceeded the configured server timeout. Generally a 503 TypeOfErrorTimeout // Rejected by a rate limit. Generally a 429 TypeOfErrorRateLimit )
const ( SRIDWGS84 = 4326 SRIDPsuedoMercator = 3857 MaxZoom = 21 )
Variables ¶
This section is empty.
Functions ¶
func AllowedLayersFromContext ¶ added in v0.6.0
Layers allowed via auth
func BackgroundContext ¶
func CachedFromContext ¶ added in v0.12.0
Whether the served tile came from the layer's cache
func CopyAuthRestrictions ¶ added in v0.12.0
func LayerPatternMatchesFromContext ¶ added in v0.6.0
Maps each layer name parameter's configured key to its value from the URL, after any paramMap replacement
func LimitAreaPartialFromContext ¶ added in v0.9.1
True means the allowed area is checked with Intersects, false with Contains
func LimitLayersFromContext ¶ added in v0.6.0
Distinguishes being restricted to no layers from being unrestricted
func RefDepthFromContext ¶ added in v0.10.0
Internal forwards via the ref provider, to guard against cycles
func ReqFromContext ¶ added in v0.6.0
func SetIdentity ¶ added in v0.12.0
Identity an offline run (seed, test) acts as, standing in for what auth sets on a real request
func StartTimeFromContext ¶ added in v0.6.0
When the request was received
func TenantIDFromContext ¶ added in v0.12.0
Set when auth can identify the tenant
Types ¶
type Bounds ¶
func AllowedAreaFromContext ¶ added in v0.6.0
Restricts the map to an area unless null island
func BoundsFromConfig ¶ added in v0.13.0
func BoundsFromConfig(b config.BoundsConfig) Bounds
func NewBoundsFromGeohash ¶
func WorldBounds ¶ added in v0.11.0
func WorldBounds() Bounds
The whole world clipped to the Web Mercator grid's latitude range. The default extent for anything unbounded
func (Bounds) BufferRelative ¶ added in v0.8.0
func (Bounds) ConfineToPsuedoMercatorRange ¶ added in v0.8.0
func (Bounds) ContainsPoint ¶ added in v0.9.1
func (Bounds) ConvertToPsuedoMercatorRange ¶ added in v0.9.1
func (Bounds) IntersectionWith ¶ added in v0.11.0
Only meaningful when the two intersect. Otherwise South > North or West > East
func (Bounds) Intersects ¶
Any part of the two bounds touch
func (Bounds) ToConfig ¶ added in v0.13.0
func (b Bounds) ToConfig() config.BoundsConfig
type Image ¶
type Image struct {
// Always an encoded file format, never raw RGB pixel values
Content []byte
// Forces the response Content-Type. Empty lets Go auto-detect. Should be a valid mime if set
ContentType string
// Prevents caching this result
ForceSkipCache bool
// Epoch seconds. Zero if unknown, e.g. decoded from a v1 payload
CreatedAt int64
}
The main result type for tiles, usually raster or vector imagery but any content type is allowed
func GetTile ¶ added in v0.10.0
func GetTile(ctx context.Context, clientConfig config.ClientConfig, url string, authHeaders map[string]string) (*Image, error)
Doesn't apply TLS profiles. Providers given a transport in their deps should use GetTileWithTransport
func GetTileWithTransport ¶ added in v0.15.0
func GetTileWithTransport(ctx context.Context, clientConfig config.ClientConfig, roundTripper http.RoundTripper, url string, authHeaders map[string]string) (*Image, error)
Applies the standard Client config: headers, timeout, allowlists, content-type rewriting and length limits. A nil transport means http.DefaultTransport. Custom Go providers should use it too
func (*Image) Encode ¶ added in v0.7.0
Combines content and content type into one byte array for caches
func (*Image) SetCreatedNow ¶ added in v0.11.0
func (i *Image) SetCreatedNow()
type InvalidArgumentError ¶
General bad input from the User
func (InvalidArgumentError) Error ¶
func (e InvalidArgumentError) Error() string
func (InvalidArgumentError) External ¶
func (e InvalidArgumentError) External(messages config.ErrorMessages) string
func (InvalidArgumentError) Type ¶
func (e InvalidArgumentError) Type() TypeOfError
type InvalidContentLengthError ¶
type InvalidContentLengthError struct {
Length int
}
The provider returned a content length the configuration doesn't allow
func (InvalidContentLengthError) Error ¶
func (e InvalidContentLengthError) Error() string
func (InvalidContentLengthError) External ¶
func (e InvalidContentLengthError) External(messages config.ErrorMessages) string
func (InvalidContentLengthError) Type ¶
func (e InvalidContentLengthError) Type() TypeOfError
type InvalidContentTypeError ¶
type InvalidContentTypeError struct {
ContentType string
}
The provider returned a content type the configuration doesn't allow
func (InvalidContentTypeError) Error ¶
func (e InvalidContentTypeError) Error() string
func (InvalidContentTypeError) External ¶
func (e InvalidContentTypeError) External(messages config.ErrorMessages) string
func (InvalidContentTypeError) Type ¶
func (e InvalidContentTypeError) Type() TypeOfError
type InvalidSridError ¶ added in v0.6.0
type InvalidSridError struct {
// contains filtered or unexported fields
}
func (InvalidSridError) Error ¶ added in v0.6.0
func (e InvalidSridError) Error() string
func (InvalidSridError) External ¶ added in v0.6.0
func (e InvalidSridError) External(messages config.ErrorMessages) string
func (InvalidSridError) Type ¶ added in v0.6.0
func (e InvalidSridError) Type() TypeOfError
type ProviderAuthError ¶
type ProviderAuthError struct {
Message string
}
Triggers a re-auth. If re-auth returns it again it's a normal provider error, not an auth one
func (ProviderAuthError) Error ¶
func (e ProviderAuthError) Error() string
func (ProviderAuthError) External ¶
func (e ProviderAuthError) External(_ config.ErrorMessages) string
func (ProviderAuthError) Type ¶
func (e ProviderAuthError) Type() TypeOfError
type RangeError ¶
A numeric User input, primarily a tile coordinate, is outside its valid range
func (RangeError) Error ¶
func (e RangeError) Error() string
func (RangeError) External ¶
func (e RangeError) External(messages config.ErrorMessages) string
func (RangeError) Type ¶
func (e RangeError) Type() TypeOfError
type RemoteConnectionError ¶ added in v0.13.0
Indicates the request to a remote server failed without a response, such as a DNS failure, refused connection, or timeout. Never includes the URL or hostname since either can hold an operator's credentials.
func (RemoteConnectionError) Error ¶ added in v0.13.0
func (e RemoteConnectionError) Error() string
func (RemoteConnectionError) External ¶ added in v0.13.0
func (e RemoteConnectionError) External(messages config.ErrorMessages) string
func (RemoteConnectionError) Type ¶ added in v0.13.0
func (e RemoteConnectionError) Type() TypeOfError
type RemoteServerError ¶
type RemoteServerError struct {
StatusCode int
}
The provider returned a status code the configuration doesn't allow
func (RemoteServerError) Error ¶
func (e RemoteServerError) Error() string
func (RemoteServerError) External ¶
func (e RemoteServerError) External(messages config.ErrorMessages) string
func (RemoteServerError) Type ¶
func (e RemoteServerError) Type() TypeOfError
type TileRequest ¶
func (TileRequest) GetBounds ¶
func (t TileRequest) GetBounds() (*Bounds, error)
func (TileRequest) GetBoundsProjection ¶ added in v0.6.0
func (t TileRequest) GetBoundsProjection(srid uint) (*Bounds, error)
func (TileRequest) IntersectsBounds ¶
func (t TileRequest) IntersectsBounds(b Bounds) (bool, error)
func (TileRequest) IntersectsBoundsProjection ¶ added in v0.6.0
func (t TileRequest) IntersectsBoundsProjection(b Bounds, srid uint) (bool, error)
func (TileRequest) StringWithSeparator ¶ added in v0.7.0
func (t TileRequest) StringWithSeparator(sep string) string
type TimeoutError ¶ added in v0.11.0
type TimeoutError struct{}
The request ran longer than the configured server timeout
func (TimeoutError) Error ¶ added in v0.11.0
func (e TimeoutError) Error() string
func (TimeoutError) External ¶ added in v0.11.0
func (e TimeoutError) External(messages config.ErrorMessages) string
func (TimeoutError) Type ¶ added in v0.11.0
func (e TimeoutError) Type() TypeOfError
type TypedError ¶
type TypedError interface {
error
Type() TypeOfError
External(errorMessages config.ErrorMessages) string
}
Separates the localized external message from the internal Error() text used for logs
type UnauthorizedError ¶
type UnauthorizedError struct {
}
Avoids returning specifics through the API so as not to help attackers
func (UnauthorizedError) Error ¶
func (e UnauthorizedError) Error() string
func (UnauthorizedError) External ¶
func (e UnauthorizedError) External(messages config.ErrorMessages) string
func (UnauthorizedError) Type ¶
func (e UnauthorizedError) Type() TypeOfError
Directories
¶
| Path | Synopsis |
|---|---|
|
entities
|
|
|
analytics
Package analytics records individual usage events per layer, coordinate and user, unlike telemetry's aggregate counters
|
Package analytics records individual usage events per layer, coordinate and user, unlike telemetry's aggregate counters |
|
ratelimit
Package ratelimit defines the stores that hold rate limit counters.
|
Package ratelimit defines the stores that hold rate limit counters. |