web

package
v0.0.0-...-fc40b91 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthcheckHandler

func HealthcheckHandler(w http.ResponseWriter, r *http.Request)

HealthcheckHandler just prints "heartbeat" to confirm the server is running

func MandelPngHandlerGenerator

func MandelPngHandlerGenerator(drawer mandelbrot.Drawer) func(w http.ResponseWriter, r *http.Request)

MandelPngHandlerGenerator takes a Drawer and returns a HttpRequestHandler. This pattern supports dependency injection for testing.

func Serve

func Serve(port int)

Serve starts a server that supports healthcheck and a mandelbrot-png endpoint

func WriteImage

func WriteImage(w http.ResponseWriter, img *image.RGBA)

WriteImage writes an image to a ResponseWriter and sets headers

Types

type DefaultMap

type DefaultMap map[string]string

DefaultMap is a string map that supports get-with-default operations

func NewDefaultMap

func NewDefaultMap(input url.Values) DefaultMap

NewDefaultMap makes a map that supports get-with-default

func (DefaultMap) GetDefaultFloat64

func (d DefaultMap) GetDefaultFloat64(key string, otherwise float64) float64

GetDefaultFloat64 gets a float from the DefaultMap if it exists and is a float, otherwise returning the default

func (DefaultMap) GetDefaultInt

func (d DefaultMap) GetDefaultInt(key string, otherwise int) int

GetDefaultInt gets an int from the DefaultMap if it exists and is an int, otherwise returning the default

Jump to

Keyboard shortcuts

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