heroku

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2016 License: BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const AcceptHeader = "application/vnd.heroku+json; version=3"

The Accept header that controls the api version. See https://devcenter.heroku.com/articles/platform-api-reference#clients

View Source
const (
	HeaderTwoFactor = "Heroku-Two-Factor-Code"
)

Variables

View Source
var (
	ErrBadRequest = &ErrorResource{
		Status:  http.StatusBadRequest,
		ID:      "bad_request",
		Message: "Request invalid, validate usage and try again",
	}
	ErrUnauthorized = &ErrorResource{
		Status:  http.StatusUnauthorized,
		ID:      "unauthorized",
		Message: "Request not authenticated, API token is missing, invalid or expired",
	}
	ErrForbidden = &ErrorResource{
		Status:  http.StatusForbidden,
		ID:      "forbidden",
		Message: "Request not authorized, provided credentials do not provide access to specified resource",
	}
	ErrNotFound = &ErrorResource{
		Status:  http.StatusNotFound,
		ID:      "not_found",
		Message: "Request failed, the specified resource does not exist",
	}
	ErrTwoFactor = &ErrorResource{
		Status:  http.StatusUnauthorized,
		ID:      "two_factor",
		Message: "Two factor code is required.",
	}
	ErrSSLRemoved = &ErrorResource{
		Status:  http.StatusNotFound,
		ID:      "not_found",
		Message: "Support for uploading SSL certificates through Empire has been removed and replaced with certificate attachments.",
		URL:     "http://empire.readthedocs.org/en/latest/ssl_certs/",
	}
	ErrMessageRequired = &ErrorResource{
		Status:  http.StatusBadRequest,
		ID:      "message_required",
		Message: fmt.Sprintf("Header '%s' is required", heroku.CommitMessageHeader),
	}
)

Named matching heroku's error codes. See https://devcenter.heroku.com/articles/platform-api-reference#error-responses

Functions

func Authenticate

func Authenticate(h httpx.Handler, auth auth.Authenticator) httpx.Handler

Authenticat wraps an httpx.Handler in the Authentication middleware to authenticate the request.

func Decode

func Decode(r *http.Request, v interface{}) error

Decode json decodes the request body into v.

func DecodeRequest added in v0.10.1

func DecodeRequest(r *http.Request, v interface{}, ignoreEOF bool) error

DecodeRequest json decodes the request body into v, optionally ignoring EOF errors to handle cases where the request body might be empty.

func Encode

func Encode(w http.ResponseWriter, v interface{}) error

Encode json encodes v into w.

func Error

func Error(w http.ResponseWriter, err error, status int) error

Error is used to respond with errors in the heroku error format, which is specified at https://devcenter.heroku.com/articles/platform-api-reference#errors

If an ErrorResource is provided as the error, and it provides a non-zero status, that will be used as the response status code.

func New

func New(e *empire.Empire, authenticator auth.Authenticator) httpx.Handler

New creates the API routes and returns a new http.Handler to serve them.

func NoContent

func NoContent(w http.ResponseWriter) error

NoContent responds with a 404 and an empty body.

func RangeHeader

func RangeHeader(r *http.Request) (headerutil.Range, error)

RangeHeader parses the Range header and returns an headerutil.Range.

func Stream

func Stream(w http.ResponseWriter, v interface{}) error

Stream encodes and flushes data to the client.

func UserFromContext added in v0.10.0

func UserFromContext(ctx context.Context) *empire.User

UserFromContext returns a user from a context.Context if one is present.

func WithUser added in v0.10.0

func WithUser(ctx context.Context, u *empire.User) context.Context

WithUser adds a user to the context.Context.

Types

type App

type App heroku.App

type Authentication

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

Middleware for handling authentication.

func (*Authentication) ServeHTTPContext

func (h *Authentication) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

ServeHTTPContext implements the httpx.Handler interface. It will ensure that there is a Bearer token present and that it is valid.

type Authorization

type Authorization heroku.OAuthAuthorization

type DeleteApp

type DeleteApp struct {
	*empire.Empire
}

func (*DeleteApp) ServeHTTPContext

func (h *DeleteApp) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type DeleteDomain

type DeleteDomain struct {
	*empire.Empire
}

func (*DeleteDomain) ServeHTTPContext

func (h *DeleteDomain) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type DeleteProcesses

type DeleteProcesses struct {
	*empire.Empire
}

func (*DeleteProcesses) ServeHTTPContext

func (h *DeleteProcesses) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type DeployApp

type DeployApp struct {
	*empire.Empire
}

func (*DeployApp) ServeHTTPContext

func (h *DeployApp) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type Domain

type Domain heroku.Domain

type Dyno

type Dyno heroku.Dyno

type ErrorResource

type ErrorResource struct {
	Status  int    `json:"-"`
	ID      string `json:"id"`
	Message string `json:"message"`
	URL     string `json:"url"`
}

ErrorResource represents the error response format that we return.

func (*ErrorResource) Error

func (e *ErrorResource) Error() string

Error implements error interface.

type Formation

type Formation heroku.Formation

type GetAppInfo

type GetAppInfo struct {
	*empire.Empire
}

func (*GetAppInfo) ServeHTTPContext

func (h *GetAppInfo) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type GetApps

type GetApps struct {
	*empire.Empire
}

func (*GetApps) ServeHTTPContext

func (h *GetApps) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type GetConfigs

type GetConfigs struct {
	*empire.Empire
}

func (*GetConfigs) ServeHTTPContext

func (h *GetConfigs) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type GetDomains

type GetDomains struct {
	*empire.Empire
}

func (*GetDomains) ServeHTTPContext

func (h *GetDomains) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type GetFormation added in v0.10.1

type GetFormation struct {
	*empire.Empire
}

GetFormation returns the current Formation info for an App

func (*GetFormation) ServeHTTPContext added in v0.10.1

func (h *GetFormation) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

ServeHTTPContext handles the http response

type GetProcesses

type GetProcesses struct {
	*empire.Empire
}

func (*GetProcesses) ServeHTTPContext

func (h *GetProcesses) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type GetRelease

type GetRelease struct {
	*empire.Empire
}

func (*GetRelease) ServeHTTPContext

func (h *GetRelease) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type GetReleases

type GetReleases struct {
	*empire.Empire
}

func (*GetReleases) ServeHTTPContext

func (h *GetReleases) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type PatchApp added in v0.10.0

type PatchApp struct {
	*empire.Empire
}

func (*PatchApp) ServeHTTPContext added in v0.10.0

func (h *PatchApp) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type PatchConfigs

type PatchConfigs struct {
	*empire.Empire
}

func (*PatchConfigs) ServeHTTPContext

func (h *PatchConfigs) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type PatchFormation

type PatchFormation struct {
	*empire.Empire
}

func (*PatchFormation) ServeHTTPContext

func (h *PatchFormation) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type PatchFormationForm

type PatchFormationForm struct {
	Updates []struct {
		Process  string              `json:"process"` // Refers to process type
		Quantity int                 `json:"quantity"`
		Size     *empire.Constraints `json:"size"`
	} `json:"updates"`
}

type PostApps

type PostApps struct {
	*empire.Empire
}

func (*PostApps) ServeHTTPContext

func (h *PostApps) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type PostAppsForm

type PostAppsForm struct {
	Name string `json:"name"`
}

type PostAuthorizations

type PostAuthorizations struct {
	*empire.Empire
}

func (*PostAuthorizations) ServeHTTPContext

func (h *PostAuthorizations) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type PostDeployForm

type PostDeployForm struct {
	Image image.Image
}

PostDeployForm is the form object that represents the POST body.

type PostDeploys

type PostDeploys struct {
	*empire.Empire
}

PostDeploys is a Handler for the POST /v1/deploys endpoint.

func (*PostDeploys) ServeHTTPContext

func (h *PostDeploys) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, req *http.Request) error

ServeHTTPContext implements the Handler interface.

type PostDomains

type PostDomains struct {
	*empire.Empire
}

func (*PostDomains) ServeHTTPContext

func (h *PostDomains) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type PostDomainsForm

type PostDomainsForm struct {
	Hostname string `json:"hostname"`
}

type PostLogs added in v0.9.2

type PostLogs struct {
	*empire.Empire
}

func (*PostLogs) ServeHTTPContext added in v0.9.2

func (h *PostLogs) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type PostLogsForm added in v0.10.1

type PostLogsForm struct {
	Duration int64
}

type PostProcess

type PostProcess struct {
	*empire.Empire
}

func (*PostProcess) ServeHTTPContext

func (h *PostProcess) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type PostProcessForm

type PostProcessForm struct {
	Command string              `json:"command"`
	Attach  bool                `json:"attach"`
	Env     map[string]string   `json:"env"`
	Size    *empire.Constraints `json:"size"`
}

type PostReleases

type PostReleases struct {
	*empire.Empire
}

func (*PostReleases) ServeHTTPContext

func (h *PostReleases) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error

type PostReleasesForm

type PostReleasesForm struct {
	Version string `json:"release"`
}

func (*PostReleasesForm) ReleaseVersion

func (p *PostReleasesForm) ReleaseVersion() (int, error)

type Release

type Release heroku.Release

Jump to

Keyboard shortcuts

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