http

package
v0.3.8-dev-trailers Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2015 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ApiUrlFormat = "http://%s%s/%s?%s"
	ApiPath      = "/api/v0" // TODO: make configurable
)
View Source
const (
	ACAOrigin      = "Access-Control-Allow-Origin"
	ACAMethods     = "Access-Control-Allow-Methods"
	ACACredentials = "Access-Control-Allow-Credentials"
)
View Source
const (
	StreamErrHeader = "X-Stream-Error"
)

Variables

View Source
var ErrNotFound = errors.New("404 page not found")

Functions

func Parse

func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error)

Parse parses the data in a http.Request and returns a command Request object

Types

type Client

type Client interface {
	Send(req cmds.Request) (cmds.Response, error)
}

Client is the commands HTTP client interface.

func NewClient

func NewClient(address string) Client

type Handler

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

The Handler struct is funny because we want to wrap our internal handler with CORS while keeping our fields.

func NewHandler

func NewHandler(ctx cmds.Context, root *cmds.Command, cfg *ServerConfig) *Handler

func (Handler) ServeHTTP

func (i Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MultiFileReader

type MultiFileReader struct {
	io.Reader
	// contains filtered or unexported fields
}

MultiFileReader reads from a `commands.File` (which can be a directory of files or a regular file) as HTTP multipart encoded data.

func NewMultiFileReader

func NewMultiFileReader(file files.File, form bool) *MultiFileReader

NewMultiFileReader constructs a MultiFileReader. `file` can be any `commands.File`. If `form` is set to true, the multipart data will have a Content-Type of 'multipart/form-data', if `form` is false, the Content-Type will be 'multipart/mixed'.

func (*MultiFileReader) Boundary

func (mfr *MultiFileReader) Boundary() string

Boundary returns the boundary string to be used to separate files in the multipart data

func (*MultiFileReader) Read

func (mfr *MultiFileReader) Read(buf []byte) (written int, err error)

type ServerConfig added in v0.3.6

type ServerConfig struct {
	// Headers is an optional map of headers that is written out.
	Headers map[string][]string

	// CORSOpts is a set of options for CORS headers.
	CORSOpts *cors.Options
}

Jump to

Keyboard shortcuts

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