server

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2018 License: Apache-2.0, BSD-2-Clause-Views, MIT Imports: 2 Imported by: 0

Documentation

Overview

Package server contains some helper function used by http server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIKeyMiddleware

func APIKeyMiddleware(apiKey string) func(next http.Handler) http.Handler

APIKeyMiddleware checks for apiKey in a request and writes http.StatusForbidden if it's incorrect.

func HeadersMiddleware

func HeadersMiddleware() func(next http.Handler) http.Handler

HeadersMiddleware sends headers required by servers

func StripTrailingSlashMiddleware

func StripTrailingSlashMiddleware() func(next http.Handler) http.Handler

StripTrailingSlashMiddleware strips trailing slash. Credit goes to https://github.com/stellar/horizon

func Write

func Write(w http.ResponseWriter, response Response)

Write writes a response to the given http.ResponseWriter

Types

type Response

type Response interface {
	HTTPStatus() int
	Marshal() []byte
}

Response represents response that can be returned by a server

Jump to

Keyboard shortcuts

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