response

package
v0.0.0-...-c490ea4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package response contains utility functions for creating HTTP responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	// contains filtered or unexported fields
}

A Response represents the content that will populate an HTTP response.

func ClickReport

func ClickReport(filename string, report <-chan *db.ClickReport) *Response

ClickReport generates a tab-separated-value file.

func Error

func Error(status int, err error) *Response

Error constructs a JSON-formatted error message.

func Func

func Func(fn func(w http.ResponseWriter) error) *Response

Func will execute an arbitrary callback to handle response construction. This is useful for streaming data responses.

func JSON

func JSON(status int, json interface{}) *Response

JSON returns the given object as a JSON blob.

func Redirect

func Redirect(status int, location string) *Response

Redirect will send the given location to the client.

func Status

func Status(status int) *Response

Status returns a trivial response.

func Text

func Text(status int, text string) *Response

Text returns the message as a JSON-formatted blob.

func (*Response) Write

func (r *Response) Write(w http.ResponseWriter) error

Write sends the response via the writer.

Jump to

Keyboard shortcuts

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