bingo

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2017 License: MIT Imports: 15 Imported by: 1

README

Bingo

Build Status

Tool for creating HTTP integration test servers.

Default template: https://github.com/sagikazarmark/manpage (Preview)

Example

See the example application here.

License

The MIT License (MIT). Please see License File for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func NewHandler

func NewHandler(b *Bin) http.Handler

Creates the HTTP Handler

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Bin

type Bin struct {
	Name             string
	ShortDescription string
	Description      string
	Endpoints        []*Endpoint
	Groups           []*Group
	IndexTemplate    string
}

func New

func New(name string, shortDescription string, description string) (*Bin, error)

Creates a new Bin

func (*Bin) AddEndpoint

func (b *Bin) AddEndpoint(endpoint *Endpoint)

Idiomatic way of adding an Endpoint without initializing the underlying slice

func (*Bin) AddGroup

func (b *Bin) AddGroup(group *Group)

Idiomatic way of adding a Group without initializing the underlying slice

func (*Bin) Index

func (b *Bin) Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

The index page listing all endpoints

type Endpoint

type Endpoint struct {
	Method      string
	Uri         *url.URL
	Handler     httprouter.Handle
	Description string
	Parameters  Parameters
	Query       url.Values
}

func NewEndpoint

func NewEndpoint(method string, uri string, handler httprouter.Handle) (*Endpoint, error)

func (*Endpoint) BuildUri

func (e *Endpoint) BuildUri() string

Prepare the URI with sane defaults

type EndpointCollector

type EndpointCollector interface {
	AddEndpoint(*Endpoint)
}

type Group

type Group struct {
	Name        string
	Description string
	Endpoints   []*Endpoint
}

Holds a list of endpoints

func NewGroup

func NewGroup(name string, description string) (*Group, error)

func (*Group) AddEndpoint

func (g *Group) AddEndpoint(endpoint *Endpoint)

Idiomatic way of adding an Endpoint without initializing the underlying slice

type Parameters

type Parameters map[string]string

func (Parameters) Set

func (p Parameters) Set(key string, value string)

Jump to

Keyboard shortcuts

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