http

package
v0.0.0-...-6e9cc21 Latest Latest
Warning

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

Go to latest
Published: May 6, 2017 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNotAcceptable = peapod.Error("not acceptable")
	ErrAssetNotFound = peapod.Error("asset not found")
)
View Source
const (
	ErrTwilioAccountMismatch = peapod.Error("twilio account mismatch")
	ErrInvalidSMSRequestBody = peapod.Error("invalid sms request body")
)
View Source
const (
	ErrTTSTextRequired = peapod.Error("tts text required")
)

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 Error

func Error(w http.ResponseWriter, r *http.Request, err error)

Error writes an error reponse to the writer.

func ErrorStatusCode

func ErrorStatusCode(err error) int

ErrorStatusCode returns the HTTP status code for an error object.

func FromContext

func FromContext(ctx context.Context) io.Writer

FromContext returns the log output stored in ctx, if any.

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 NewContext

func NewContext(ctx context.Context, logOutput io.Writer) context.Context

NewContext returns a new Context that carries the log output.

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 Server

type Server struct {

	// Services
	FileService     peapod.FileService
	JobService      peapod.JobService
	PlaylistService peapod.PlaylistService
	SMSService      peapod.SMSService
	TrackService    peapod.TrackService
	UserService     peapod.UserService

	// Server options.
	Addr        string // bind address
	Host        string // external hostname
	Autocert    bool   // ACME autocert
	Recoverable bool   // panic recovery

	// Twilio specific options.
	Twilio struct {
		AccountSID string // twilio account number
	}

	LogOutput io.Writer
	// contains filtered or unexported fields
}

Server represents an HTTP server.

func NewServer

func NewServer() *Server

NewServer returns a new instance of Server.

func (*Server) Close

func (s *Server) Close() error

Close closes the socket.

func (*Server) Open

func (s *Server) Open() error

Open opens the server.

func (*Server) URL

func (s *Server) URL() url.URL

URL returns a base URL string with the scheme and host. This is available after the server has been opened.

Jump to

Keyboard shortcuts

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