apistuff

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: BSD-2-Clause Imports: 7 Imported by: 1

Documentation

Overview

apistuff is a package of helpers and handlers that are for slimlining the development of web APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCookieByName

func GetCookieByName(cookies []*http.Cookie, name string) string

GetCookieByName scans the cookies and returns one with a matching key, if there is one.

func HandleHealthOK

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

handleHealth simply returns a status struct that says the service is healthy

func HttpError

func HttpError(w http.ResponseWriter, message string, code int)

func StatusMessage

func StatusMessage(status, message string) ([]byte, error)

func WriteTempFile

func WriteTempFile(input io.Reader, fname string, prefix string) (filename string, err error)

writeTempFile will stream a reader out to a temporary file, with the filename being the fname passed, written to a temporary dir. The whole filepath is returned.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Used to stub out time in testing

type SystemClock

type SystemClock struct{}

func (SystemClock) Now

func (s SystemClock) Now() time.Time

Jump to

Keyboard shortcuts

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