http

package
v0.0.0-...-a8e4d9d Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorMessageFromBraintreeAboutCanceledSubscription = "Subscription has already been canceled."
)
View Source
const (
	StatusUnprocessableEntity = 422 // from WebDAV
)

Variables

View Source
var (
	ErrRecoveredFromPanic   = NewError(500, "recovered_from_panic", "Recovered from panic")
	ErrNotFound             = NewError(404, "not_found", "Not found")
	ErrUnexpectedEOF        = NewError(400, "unexpected_eof", "Unexpected EOF")
	ErrSessionExpired       = NewError(403, "session_expired", "Session expired")
	ErrSessionNotFound      = NewError(403, "session_not_found", "Session not found")
	ErrSessionNotValid      = NewError(403, "session_not_valid", "Session not valid (validated)")
	ErrSessionInvalidated   = NewError(403, "session_invalidated", "Session invalidated")
	ErrRateLimitExceeded    = NewError(403, "rate_limit_exceeded", "Rate limit exceeded")
	ErrLimitsExceeded       = NewError(403, "limits_exceeded", "Billing plan limits exceeded")
	ErrSessionUserNotFound  = NewError(403, "session_user_not_found", "Session user not found")
	ErrSessionUuidMalformed = NewError(400, "session_uuid_malformed", "Session UUID malformed")
	ErrLoginRequired        = NewError(403, "login_required", "Login required")
	ErrUserBlocked          = NewError(403, "user_blocked", "User blocked")
)
View Source
var (
	AllowedWithInvalidatedSession = regexp.MustCompile(`/(sessions/|api-features)`)
)

Functions

func BraintreeNotificationToBillingEventData

func BraintreeNotificationToBillingEventData(notification *braintree.WebhookNotification) (*domain.BillingPlanSubscriptionChanged, error)

func CurrentUser

func CurrentUser(c *config.Config, tx *sqlx.Tx, sessionUuid string) (*domain.User, error)

returns either - User, nil when the Session is valid - nil, error when an error occured - nil, nil when the Session is invalid, or the sessionId is empty

func HandlerFunc

func HandlerFunc(ctxt ServerContext, h Handler) http.Handler

func MountActivitiesHandler

func MountActivitiesHandler(r *mux.Router, ctxt ServerContext)

func MountBillingPlanHandler

func MountBillingPlanHandler(r *mux.Router, ctxt ServerContext)

func MountCapistranoHandler

func MountCapistranoHandler(r *mux.Router, ctxt ServerContext)

func MountDeliveryHandler

func MountDeliveryHandler(r *mux.Router, ctxt ServerContext)

func MountEmailNotifierHandler

func MountEmailNotifierHandler(r *mux.Router, ctxt ServerContext)

func MountEnvironmentHandler

func MountEnvironmentHandler(r *mux.Router, ctxt ServerContext)

func MountFeaturesHandler

func MountFeaturesHandler(r *mux.Router, ctxt ServerContext)

func MountGitTriggerHandler

func MountGitTriggerHandler(r *mux.Router, ctxt ServerContext)

func MountIndexHandler

func MountIndexHandler(r *mux.Router, ctxt ServerContext)

func MountInvitationHandler

func MountInvitationHandler(r *mux.Router, ctxt ServerContext)

func MountJobHandler

func MountJobHandler(r *mux.Router, ctxt ServerContext)

func MountJobNotifierHandler

func MountJobNotifierHandler(r *mux.Router, ctxt ServerContext)

func MountLogHandler

func MountLogHandler(r *mux.Router, ctxt ServerContext)

func MountNotificationRuleHandler

func MountNotificationRuleHandler(r *mux.Router, ctxt ServerContext)

func MountOAuthHandler

func MountOAuthHandler(r *mux.Router, ctxt ServerContext)

func MountOperationHandler

func MountOperationHandler(r *mux.Router, ctxt ServerContext)

func MountOrganizationHandler

func MountOrganizationHandler(r *mux.Router, ctxt ServerContext)

func MountPasswordResetHandler

func MountPasswordResetHandler(r *mux.Router, ctxt ServerContext)

func MountProjectHandler

func MountProjectHandler(r *mux.Router, ctxt ServerContext)

func MountProjectMemberHandler

func MountProjectMemberHandler(r *mux.Router, ctxt ServerContext)

func MountPromptHandler

func MountPromptHandler(r *mux.Router, ctxt ServerContext)

func MountRepoHandler

func MountRepoHandler(r *mux.Router, ctxt ServerContext)

func MountRepoPreflightHandler

func MountRepoPreflightHandler(r *mux.Router, ctxt ServerContext)

func MountScheduleHandler

func MountScheduleHandler(r *mux.Router, ctxt ServerContext)

func MountScriptEditorHandler

func MountScriptEditorHandler(r *mux.Router, ctxt ServerContext)

func MountSecretHandler

func MountSecretHandler(r *mux.Router, ctxt ServerContext)

func MountSessionHandler

func MountSessionHandler(r *mux.Router, ctxt ServerContext)

func MountSlackNotifierHandler

func MountSlackNotifierHandler(r *mux.Router, ctxt ServerContext)

func MountStencilHandler

func MountStencilHandler(r *mux.Router, ctxt ServerContext)

func MountTaskHandler

func MountTaskHandler(r *mux.Router, ctxt ServerContext)

func MountUserHandler

func MountUserHandler(r *mux.Router, ctxt ServerContext)

func MountUserVerificationHandler

func MountUserVerificationHandler(r *mux.Router, ctxt ServerContext)

func MountWebhookHandler

func MountWebhookHandler(r *mux.Router, ctxt ServerContext)

func NewLimitsFromContext

func NewLimitsFromContext(ctxt RequestContext) *limits.Client

func NewScriptEditParamsFromJSON

func NewScriptEditParamsFromJSON(in io.Reader) (*scriptEditParams, error)

func NewSubscribeParams

func NewSubscribeParams(src io.Reader) (*subscribeParams, error)

func ReadCreateUserParams

func ReadCreateUserParams(r io.Reader) (*createUserParams, error)

func ReadEnvParams

func ReadEnvParams(r io.Reader) (*envParams, error)

func ReadJobParams

func ReadJobParams(r io.Reader) (*jobParams, error)

func ReadPatchUserParams

func ReadPatchUserParams(r io.Reader) (*patchUserParams, error)

func ReadRepoParams

func ReadRepoParams(r io.Reader) (*repoParams, error)

func ReadSchedParams

func ReadSchedParams(r io.Reader) (*schedParams, error)

func ReadSecretParams

func ReadSecretParams(r io.Reader) (*secretParams, error)

func ReadSessionCreateParams

func ReadSessionCreateParams(r io.Reader) (*createSessionParams, error)

func ReadSessionPatchParams

func ReadSessionPatchParams(r io.Reader) (*patchSessionParams, error)

func ReadTaskParams

func ReadTaskParams(r io.Reader) (*taskParams, error)

Types

type ActivitySink

type ActivitySink interface {
	EmitActivity(activity *domain.Activity)
}

An ActivitySink is used for emitting activities over some form of messaging system.

type AddCreditCardRequest

type AddCreditCardRequest struct {
	Nonce            string `json:"nonce"`
	OrganizationUuid string `json:"organizationUuid"`
}

type BraintreePurchaseRequest

type BraintreePurchaseRequest struct {
	PlanUuid         string `json:"planUuid"`
	OrganizationUuid string `json:"organizationUuid"`
}

type BusActivitySink

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

func NewBusActivitySink

func NewBusActivitySink(bus activity.Sink) *BusActivitySink

func (*BusActivitySink) EmitActivity

func (self *BusActivitySink) EmitActivity(activity *domain.Activity)

type BusSink

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

BusSink sends activities over an activity bus

func NewBusSink

func NewBusSink(bus activity.Sink) *BusSink

func (*BusSink) EmitActivity

func (self *BusSink) EmitActivity(activity *domain.Activity)

type CapistranoSignUpParameters

type CapistranoSignUpParameters struct {
	Name          string `json:"name"`
	Password      string `json:"password"`
	Email         string `json:"email"`
	RepositoryURL string `json:"repository_url"`
}

func (*CapistranoSignUpParameters) OrganizationName

func (params *CapistranoSignUpParameters) OrganizationName() string

func (*CapistranoSignUpParameters) ProjectName

func (params *CapistranoSignUpParameters) ProjectName() string

type CapistranoSignUpResponse

type CapistranoSignUpResponse struct {
	OrganizationUuid string `json:"organization_uuid"`
	ProjectUuid      string `json:"project_uuid"`
	SessionUuid      string `json:"session_uuid"`
	OrganizationName string `json:"organization_name"`
	ProjectName      string `json:"project_name"`
}

type CardsByProjectUuid

type CardsByProjectUuid struct {
	Cards map[string]*domain.ProjectCard
	Order []string
}

func (*CardsByProjectUuid) Len

func (self *CardsByProjectUuid) Len() int

func (*CardsByProjectUuid) Less

func (self *CardsByProjectUuid) Less(i int, j int) bool

func (*CardsByProjectUuid) ProjectCards

func (self *CardsByProjectUuid) ProjectCards() []*domain.ProjectCard

func (*CardsByProjectUuid) Swap

func (self *CardsByProjectUuid) Swap(i int, j int)

func (*CardsByProjectUuid) UnmarshalJSON

func (self *CardsByProjectUuid) UnmarshalJSON(data []byte) error

type ClientTokenResponse

type ClientTokenResponse struct {
	ClientToken string `json:"clientToken"`
	Error       string `json:"error,omitempty"`
}

type CollectionPage

type CollectionPage struct {
	Total      int
	Count      int
	Collection []interface{}
}

type CreateInvitationParams

type CreateInvitationParams struct {
	RecipientName  string `json:"recipientName"`
	Email          string `json:"email"`
	InviteeUuid    string `json:"inviteeUuid"`
	ProjectUuid    string `json:"projectUuid"`
	MembershipType string `json:"membershipType"`
	Message        string `json:"message"`
}

type EmailNotifierHandler

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

func (*EmailNotifierHandler) Archive

func (h *EmailNotifierHandler) Archive(ctxt RequestContext) error

func (*EmailNotifierHandler) Create

func (h *EmailNotifierHandler) Create(ctxt RequestContext) error

func (*EmailNotifierHandler) Show

func (*EmailNotifierHandler) Update

func (h *EmailNotifierHandler) Update(ctxt RequestContext) error

type Error

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

Error represents an error response from the API. Its responsibility is to ensure that all errors returned by the API have are properly structured.

func NewCapabilityMissingError

func NewCapabilityMissingError(haveCapabilities map[string]bool, missingCapability string) *Error

func NewError

func NewError(status int, code, msg string) *Error

func NewInternalError

func NewInternalError(err error) *Error

func NewMalformedParameters

func NewMalformedParameters(param string, err error) *Error

func NewOAuthError

func NewOAuthError(provider string, reason string, err error) *Error

func NewValidationError

func NewValidationError(src *domain.ValidationError) *Error

func (*Error) AsJSON

func (self *Error) AsJSON() []byte

func (*Error) Error

func (e *Error) Error() string

func (*Error) MarshalJSON

func (self *Error) MarshalJSON() ([]byte, error)

type ErrorJSON

type ErrorJSON struct {
	// Reason is a machine readable identifier for the error.
	// Use this identifier for translating error messages.
	Reason string `json:"reason"`

	// Message is a human readable string describing this instance
	// of the error, such as the location at which a parse error
	// occurred.
	Message string `json:"message"`

	// Errors maps input parameter names to error identifiers
	// pertaining to that parameter:
	//
	//    { "field": ["parse_error"] }
	Errors map[string][]string `json:"errors,omitempty"`
}

ErrorJSON is the serialized form of an API error ("wire format").

type Getter

type Getter interface {
	Get(key string) string
}

type GitTriggerHandler

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

func (*GitTriggerHandler) Archive

func (h *GitTriggerHandler) Archive(ctxt RequestContext) error

func (*GitTriggerHandler) Create

func (h *GitTriggerHandler) Create(ctxt RequestContext) error

func (*GitTriggerHandler) Show

func (h *GitTriggerHandler) Show(ctxt RequestContext) error

func (*GitTriggerHandler) Update

func (h *GitTriggerHandler) Update(ctxt RequestContext) error

type Handler

type Handler func(RequestContext) error

type JobNotifierHandler

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

func (*JobNotifierHandler) Archive

func (h *JobNotifierHandler) Archive(ctxt RequestContext) error

func (*JobNotifierHandler) Create

func (h *JobNotifierHandler) Create(ctxt RequestContext) error

func (*JobNotifierHandler) Show

func (h *JobNotifierHandler) Show(ctxt RequestContext) error
type Links map[string]map[string]string

type NotificationRuleHandler

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

func (*NotificationRuleHandler) Archive

func (h *NotificationRuleHandler) Archive(ctxt RequestContext) error

func (*NotificationRuleHandler) Create

func (*NotificationRuleHandler) Show

func (*NotificationRuleHandler) Update

type NullSink

type NullSink struct{}

NullSink is the default activity sink which does nothing

func NewNullSink

func NewNullSink() *NullSink

func (*NullSink) EmitActivity

func (sink *NullSink) EmitActivity(activity *domain.Activity)

type OrgParams

type OrgParams struct {
	Uuid        string `json:"uuid"`
	Name        string `json:"name"`
	Public      bool   `json:"public"`
	GithubLogin string `json:"github_login"`
	PlanUuid    string `json:"planUuid"`
}

type OrgParamsWrapper

type OrgParamsWrapper struct {
	Subject OrgParams
}

func ReadOrgParams

func ReadOrgParams(r io.Reader) (*OrgParamsWrapper, error)

type PatchInvitationParams

type PatchInvitationParams struct {
	Accept string `json:"accept"`
}

func (*PatchInvitationParams) AcceptsInvitation

func (p *PatchInvitationParams) AcceptsInvitation() bool

func (*PatchInvitationParams) RefusesInvitation

func (p *PatchInvitationParams) RefusesInvitation() bool

type ProjectParams

type ProjectParams struct {
	Uuid             string `json:"uuid"`
	Name             string `json:"name"`
	OrganizationUuid string `json:"organizationUuid"`
	Public           bool   `json:"public"`
}

func ReadProjectParams

func ReadProjectParams(r io.Reader) (*ProjectParams, error)

type ProjectPararamsWrapper

type ProjectPararamsWrapper struct {
	Subject ProjectParams
}

type RequestContext

type RequestContext interface {
	ServerContext

	// R returns the current HTTP request.
	R() *http.Request
	// W return the http.ResponseWriter of the current HTTP request.
	W() http.ResponseWriter

	// User returns the user who is currently logged in.
	User() *domain.User

	// Auth provides access to the authorization logic.
	Auth() authz.Service

	// Tx returns the request-scoped database transaction.
	// Multiple calls to Tx have to return the same transaction.
	Tx() *sqlx.Tx

	// CommitTx commits the current transaction, as returned by Tx.
	// This method exists for testing purposes.
	CommitTx() error

	// Rollback the Tx() in case of an error
	RollbackTx()

	// PathParameter returns the path parameter identified by key
	// for the current request.
	PathParameter(key string) string

	// EnqueueActivity records enqueues an activity for emitting it
	// when the request's database transaction has succeeded.
	//
	// If userUuid is non-nil, its value is used as id of the user
	// triggering the activity.
	EnqueueActivity(activity *domain.Activity, userUuid *string)

	// Activities returns all activities that have been enqueued
	// for later emittal.
	Activities() []*domain.Activity
}

A RequestContext extends ServerContext by providing access to request specific variables.

type ScheduledExecutionsParams

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

func NewScheduledExecutionsParams

func NewScheduledExecutionsParams(params Getter) (*ScheduledExecutionsParams, error)

type SecretChanges

type SecretChanges struct {
	Added   []domain.OperationSecret `json:"added"`
	Removed []domain.OperationSecret `json:"removed"`
	Changed []domain.OperationSecret `json:"changed"`
}

type ServerContext

type ServerContext interface {
	// Config returns the server-wide configuration
	Config() config.Config

	// Returns a stores.KeyValueStore to be used for non-sensitive data.
	KeyValueStore() stores.KeyValueStore
	// Returns a stores.KeyValueStore to be used for secret data.
	SecretKeyValueStore() stores.SecretKeyValueStore

	Log() logger.Logger
	SetLogger(logger.Logger)

	// RequestContext returns a new context with valid values for
	// all request specific variables
	RequestContext(w http.ResponseWriter, req *http.Request) (RequestContext, error)
}

ServerContext provides access to objects that are needed for fulfilling HTTP requests. Objects exposed are expected to be accessed by multiple goroutines.

func NewStandardContext

func NewStandardContext(db *sqlx.DB, c *config.Config, kv stores.KeyValueStore, ss stores.SecretKeyValueStore) ServerContext

NewContext returns a new context with some sane defaults, over write them if you like

func NewStandardContextTx

func NewStandardContextTx(db *sqlx.DB, tx *sqlx.Tx, c *config.Config, kv stores.KeyValueStore, ss stores.SecretKeyValueStore) ServerContext

NewStandardContextTx returns a new context initialized with the given DB connection, transaction and configuration.

type SlackNotifierHandler

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

func (*SlackNotifierHandler) Archive

func (h *SlackNotifierHandler) Archive(ctxt RequestContext) error

func (*SlackNotifierHandler) Create

func (h *SlackNotifierHandler) Create(ctxt RequestContext) error

func (*SlackNotifierHandler) Show

func (*SlackNotifierHandler) Update

func (h *SlackNotifierHandler) Update(ctxt RequestContext) error

Jump to

Keyboard shortcuts

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