Documentation ¶
Index ¶
- Constants
- Variables
- func Authenticate(h httpx.Handler, auth auth.Authenticator) httpx.Handler
- func Decode(r *http.Request, v interface{}) error
- func DecodeRequest(r *http.Request, v interface{}, ignoreEOF bool) error
- func Encode(w http.ResponseWriter, v interface{}) error
- func Error(w http.ResponseWriter, err error, status int) error
- func New(e *empire.Empire, authenticator auth.Authenticator) httpx.Handler
- func NoContent(w http.ResponseWriter) error
- func RangeHeader(r *http.Request) (headerutil.Range, error)
- func Stream(w http.ResponseWriter, v interface{}) error
- func UserFromContext(ctx context.Context) *empire.User
- func WithUser(ctx context.Context, u *empire.User) context.Context
- type App
- type Authentication
- type Authorization
- type DeleteApp
- type DeleteDomain
- type DeleteProcesses
- type DeployApp
- type Domain
- type Dyno
- type ErrorResource
- type Formation
- type GetAppInfo
- type GetApps
- type GetConfigs
- type GetDomains
- type GetFormation
- type GetProcesses
- type GetRelease
- type GetReleases
- type PatchApp
- type PatchConfigs
- type PatchFormation
- type PatchFormationForm
- type PostApps
- type PostAppsForm
- type PostAuthorizations
- type PostDeployForm
- type PostDeploys
- type PostDomains
- type PostDomainsForm
- type PostLogs
- type PostLogsForm
- type PostProcess
- type PostProcessForm
- type PostReleases
- type PostReleasesForm
- type Release
Constants ¶
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
const (
HeaderTwoFactor = "Heroku-Two-Factor-Code"
)
Variables ¶
var ( ErrBadRequest = &ErrorResource{ Status: http.StatusBadRequest, ID: "bad_request", Message: "Request invalid, validate usage and try again", } 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 ¶
Authenticat wraps an httpx.Handler in the Authentication middleware to authenticate the request.
func DecodeRequest ¶ added in v0.10.1
DecodeRequest json decodes the request body into v, optionally ignoring EOF errors to handle cases where the request body might be empty.
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 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
UserFromContext returns a user from a context.Context if one is present.
Types ¶
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 ¶
func (*DeleteApp) ServeHTTPContext ¶
type DeleteDomain ¶
func (*DeleteDomain) ServeHTTPContext ¶
func (h *DeleteDomain) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error
type DeleteProcesses ¶
func (*DeleteProcesses) ServeHTTPContext ¶
func (h *DeleteProcesses) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error
type DeployApp ¶
func (*DeployApp) ServeHTTPContext ¶
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 GetAppInfo ¶
func (*GetAppInfo) ServeHTTPContext ¶
func (h *GetAppInfo) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error
type GetApps ¶
func (*GetApps) ServeHTTPContext ¶
type GetConfigs ¶
func (*GetConfigs) ServeHTTPContext ¶
func (h *GetConfigs) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error
type GetDomains ¶
func (*GetDomains) ServeHTTPContext ¶
func (h *GetDomains) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error
type GetFormation ¶ added in v0.10.1
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 ¶
func (*GetProcesses) ServeHTTPContext ¶
func (h *GetProcesses) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error
type GetRelease ¶
func (*GetRelease) ServeHTTPContext ¶
func (h *GetRelease) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error
type GetReleases ¶
func (*GetReleases) ServeHTTPContext ¶
func (h *GetReleases) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error
type PatchApp ¶ added in v0.10.0
func (*PatchApp) ServeHTTPContext ¶ added in v0.10.0
type PatchConfigs ¶
func (*PatchConfigs) ServeHTTPContext ¶
func (h *PatchConfigs) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error
type PatchFormation ¶
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 ¶
func (*PostApps) ServeHTTPContext ¶
type PostAppsForm ¶
type PostAppsForm struct {
Name string `json:"name"`
}
type PostAuthorizations ¶
func (*PostAuthorizations) ServeHTTPContext ¶
func (h *PostAuthorizations) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error
type PostDeployForm ¶
PostDeployForm is the form object that represents the POST body.
type PostDeploys ¶
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 ¶
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
func (*PostLogs) ServeHTTPContext ¶ added in v0.9.2
type PostLogsForm ¶ added in v0.10.1
type PostLogsForm struct {
Duration int64
}
type PostProcess ¶
func (*PostProcess) ServeHTTPContext ¶
func (h *PostProcess) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request) error
type PostProcessForm ¶
type PostReleases ¶
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)