response

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2018 License: MPL-2.0 Imports: 9 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, err string, code int)

Error produces a JSON error response with the following structure: {"error":"some error message"}

func NoContent

func NoContent(w http.ResponseWriter)

NoContent writes a 204 no content response

func UnauthorizedError

func UnauthorizedError(w http.ResponseWriter, err string)

UnauthorizedError has to contain WWW-Authenticate header See http://self-issued.info/docs/draft-ietf-oauth-v2-bearer.html#rfc.section.3

func WriteJSON

func WriteJSON(w http.ResponseWriter, v interface{}, code int)

WriteJSON writes JSON response

Types

type ListResponse

type ListResponse struct {
	jsonhal.Hal
	Count uint `json:"count"`
	Page  uint `json:"page"`
}

ListResponse ...

func NewListResponse

func NewListResponse(count, page int, self, first, last, previous, next, embedName string, items interface{}) *ListResponse

NewListResponse creates new ListResponse instance

type Logger

type Logger struct {
	// Logger inherits from log.Logger used to log messages with the Logger middleware
	*log.Logger
}

Logger is a middleware handler that logs the request as it goes in and the response as it goes out.

func NewURLLogger

func NewURLLogger() *Logger

NewURLLogger returns a new Logger instance

func (*Logger) ServeHTTP

func (l *Logger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type LookupStringIDResponse

type LookupStringIDResponse struct {
	jsonhal.Hal
	ID        string `json:"id"`
	Name      string `json:"name"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

LookupStringIDResponse ...

type LookupUintIDResponse

type LookupUintIDResponse struct {
	jsonhal.Hal
	ID        uint   `json:"id"`
	Name      string `json:"name"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

LookupUintIDResponse ...

Jump to

Keyboard shortcuts

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