data

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

package data provides wrappers for response data, optionally including response headers such as ETag.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data interface {
	// Content returns the data as a value that can be processed by encoders such as "encoding/json"
	Content(template, language string) (interface{}, error)

	// Headers returns response headers relating to the data (optional)
	Headers() map[string]string
}

type Value

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

Value is a simple implementation of Data.

func Lazy

func Lazy(fn func(template, language string) (interface{}, error)) Value

Lazy wraps a function that supplies a data value, but only when it is needed.

func Of

func Of(v interface{}) Value

Of wraps a data value.

func (Value) Content

func (v Value) Content(template, language string) (interface{}, error)

func (Value) Headers

func (v Value) Headers() map[string]string

func (Value) With

func (v Value) With(hdr, value string, others ...string) Value

With returns a copy of v with extra headers attached. These are passed in as key+value pairs. The header names should be in normal form, e.g. "Last-Modified" instead of "last-modified", but this is not mandatory.

Jump to

Keyboard shortcuts

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