api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheModifier added in v0.2.0

func CacheModifier(cfg Config, parentModifier func(r *http.Response) error) func(*http.Response) error

CacheModifier returns a ResponseModifier that sets a maximum cache header It optionally takes another response modifier that it wraps around and performs first when called

func CreateOSMapsProxy added in v0.2.0

func CreateOSMapsProxy(target *url.URL, cfg Config, responseModifier func(r *http.Response) error) *httputil.ReverseProxy

CreateOSMapsProxy returns a ReverseProxy that modifies requests to add an Ordnance Survey api key and forward them on to the O/S api. It can also optionally modify the response (for example the URLS contained in the response)

func StringReplaceResponseModifier added in v0.2.0

func StringReplaceResponseModifier(from, to string) func(*http.Response) error

StringReplaceResponseModifier returns a function that takes in a pointer to a Response object that modifies that response by changing every instance of a string in the body to another string.

Types

type API

type API struct {
	Router *mux.Router
}

API provides a struct to wrap the api around

func Setup

func Setup(ctx context.Context, cfg Config, r *mux.Router) (*API, error)

Setup function sets up the api and returns an api

type Config added in v0.2.0

type Config struct {
	MapsAPIURL           string
	OrdnanceSurveyAPIURL *url.URL
	OrdnanceSurveyAPIKey string
	CacheMaxAge          time.Duration
}

Config is a struct that contains configuration values required by the API

Jump to

Keyboard shortcuts

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