handler
v1.1.1
Documentation
pkg.go.dev ↗Types
API
type API struct {
Namespace
// Prefix is the part of the URL under which the API is being served, for
// example "/api".
Prefix string
}
API is the handler for handling API requests made for namespace creation, and management.
API.Destroy
func (h API) Destroy(w http.ResponseWriter, r *http.Request)
Destroy removes the namespace in the given request context from the database. This serves no content in the response body.
API.Index
func (h API) Index(w http.ResponseWriter, r *http.Request)
Index serves the JSON encoded list of namespaces for the given request. If multiple pages of namespaces are returned then the database.Paginator is encoded in the Link response header.
API.Show
func (h API) Show(w http.ResponseWriter, r *http.Request)
Show serves up the JSON response for the namespace in the given request. This serves different responses based on the base path of the request URL.
API.Store
func (h API) Store(w http.ResponseWriter, r *http.Request)
Store stores the namespace from the given request body. If any validation errors occur then these will be sent back in the JSON response. On success the build is sent in the JSON response.
API.Update
func (h API) Update(w http.ResponseWriter, r *http.Request)
Update applies the changes in the given request body to the existing namespace in the database. If any validation errors occur then these will be sent back in the JSON response. On success the updated namespace is sent in the JSON response.
Collaborator
type Collaborator struct {
web.Handler
}
Collaborator is the base handler that provides shared logic for the UI and API handlers for working with namespace collaborators.
Collaborator.DeleteModel
func (h Collaborator) DeleteModel(r *http.Request) error
DeleteModel deletes the specified collaborator in the request from the namespace in the given request context. Upon deletion this will modify the ownership of any resources created by the original collaborator to the owner of the namespace.
CollaboratorAPI
type CollaboratorAPI struct {
Collaborator
// Prefix is the part of the URL under which the API is being served, for
// example "/api".
Prefix string
}
CollaboratorAPI is the handler for handling API requests made for managing a namespace's collaborators.
CollaboratorAPI.Destroy
func (h CollaboratorAPI) Destroy(w http.ResponseWriter, r *http.Request)
Destroy removes the collaborator in the given request context from the database. This serves no content in the response body.
CollaboratorAPI.Index
func (h CollaboratorAPI) Index(w http.ResponseWriter, r *http.Request)
Index serves the JSON encoded list of collaborators for the given request.
CollaboratorUI
type CollaboratorUI struct {
Collaborator
}
CollaboratorUI is the handler for handling UI requests made for managing namespace collaborators.
CollaboratorUI.Destroy
func (h CollaboratorUI) Destroy(w http.ResponseWriter, r *http.Request)
Destroy removes the given namespace collaborator in the request from the namespace.
CollaboratorUI.Index
func (h CollaboratorUI) Index(w http.ResponseWriter, r *http.Request)
Index serves the HTML response detailing the list of namespace collaborators.
Invite
type Invite struct {
web.Handler
// contains filtered or unexported fields
}
Invite is the base handler that provides shared logic for the UI and API handlers for working with build namespace invites.
NewInvite
func NewInvite(h web.Handler) Invite
Invite.Accept
func (h Invite) Accept(r *http.Request) (*namespace.Namespace, *user.User, *user.User, error)
Accept accepts an invite in the given request, and adds the user the invite was sent to as a collaborator to the invite's namespace. Upon success this will return the namespace the user was invited to, the user who sent the invite, and the user who received the invite.
Invite.DeleteModel
func (h Invite) DeleteModel(r *http.Request) error
DeleteModel deletes the namespace invite in the given request context from the database.
Invite.IndexWithRelations
func (h Invite) IndexWithRelations(s *namespace.InviteStore) ([]*namespace.Invite, error)
IndexWithRelations returns all of the namespace invites with their relationships loaded into each return invite.
Invite.StoreModel
func (h Invite) StoreModel(r *http.Request) (*namespace.Invite, namespace.InviteForm, error)
StoreModel unmarshals the request's data into an invite, validates it and stores it in the database. Upon success this will return the newly created invite. This also returns the form for sending an invite.
InviteAPI
type InviteAPI struct {
Invite
// Prefix is the part of the URL under which the API is being served, for
// example "/api".
Prefix string
}
InviteAPI is the handler for handling API requests made for sending and receiving namespace invites.
InviteAPI.Destroy
func (h InviteAPI) Destroy(w http.ResponseWriter, r *http.Request)
Destroy removes the invite in the given request context from the database. This serves no content in the response body.
InviteAPI.Index
func (h InviteAPI) Index(w http.ResponseWriter, r *http.Request)
Index serves the JSON encoded list of invites for the given request.
InviteAPI.Store
func (h InviteAPI) Store(w http.ResponseWriter, r *http.Request)
Store stores and submits the invite from the given request body. If any validation errors occur then these will be sent back in the JSON response. On success the invite is sent in the JSON response.
InviteAPI.Update
func (h InviteAPI) Update(w http.ResponseWriter, r *http.Request)
Update will accept the invite in the given request context. This will send back the JSON response containing the namespace the invite was for, along with the inviter and invitee.
InviteUI
type InviteUI struct {
Invite
}
InviteUI is the handler for handling UI requests made for sending and receiving namespace invites.
InviteUI.Destroy
func (h InviteUI) Destroy(w http.ResponseWriter, r *http.Request)
Destroy will delete the invite in the request's context from the database.
InviteUI.Index
func (h InviteUI) Index(w http.ResponseWriter, r *http.Request)
Index serves the HTML response detailing the list of namespace invites.
InviteUI.Store
func (h InviteUI) Store(w http.ResponseWriter, r *http.Request)
Store validates the form submitted in the given request for sending an invite.
InviteUI.Update
func (h InviteUI) Update(w http.ResponseWriter, r *http.Request)
Update accepts the invite in the given request context. Upon success this will redirect back to the request referer.
Namespace
type Namespace struct {
web.Handler
// contains filtered or unexported fields
}
Namespace is the base handler that provides shared logic for the UI and API handlers for namespace creation, and management.
New
func New(h web.Handler) Namespace
Namespace.Create
func (h Namespace) Create(w http.ResponseWriter, r *http.Request)
Create serves the HTML response for creating namespaces via the web frontend.
Namespace.DeleteModel
func (h Namespace) DeleteModel(r *http.Request) error
DeleteModel removes the namespace and all of its children in the given request context from the database.
Namespace.Index
func (h Namespace) Index(w http.ResponseWriter, r *http.Request)
Index serves the HTML response detailing the list of namespaces.
Namespace.IndexWithRelations
func (h Namespace) IndexWithRelations(s *namespace.Store, vals url.Values) ([]*namespace.Namespace, database.Paginator, error)
IndexWithRelations retreives a slice of *namespace.Namespace models for the user in the given request context. All of the relations for each namespace will be loaded into each model we have. A database.Paginator will also be returned if there are multiple pages of namespaces.
Namespace.Show
func (h Namespace) Show(w http.ResponseWriter, r *http.Request)
Show serves the HTML response for viewing an individual namespace in the given request. This serves different responses based on the base path of the request URL.
Namespace.Store
func (h Namespace) Store(w http.ResponseWriter, r *http.Request)
Store validates the form submitted in the given request for creating a namespace. If validation fails then the user is redirected back to the request referer, otherwise they are redirect back to the namespace index.
Namespace.StoreModel
func (h Namespace) StoreModel(r *http.Request) (*namespace.Namespace, namespace.Form, error)
StoreModel unmarshals the request's data into a namespace, validates it and stores it in the database. Upon success this will return the newly created namespace. This also returns the form for creating a namespace.
Namespace.UpdateModel
func (h Namespace) UpdateModel(r *http.Request) (*namespace.Namespace, namespace.Form, error)
UpdateModel unmarshals the request's data into a namespace, validates it and updates the existing namespace in the database with the content in the form. Upon success the updated namespace is returned. This also returns the form for modifying a namespace.
UI
type UI struct {
Namespace
}
UI is the handler for handling UI requests made for namespace creation, and management.
UI.Badge
func (h UI) Badge(w http.ResponseWriter, r *http.Request)
Badge renders an SVG badge of the latest build in the namespace, if any.
UI.Destroy
func (h UI) Destroy(w http.ResponseWriter, r *http.Request)
Destroy removes the namespace in the given request context from the database. This redirects back to the namespace index upon success.
UI.Edit
func (h UI) Edit(w http.ResponseWriter, r *http.Request)
Edit serves the HTML response for editing the namespace in the given request context.
UI.Update
func (h UI) Update(w http.ResponseWriter, r *http.Request)
Update validates the form submitted in the given request for updating a namespace. If validation fails then the user is redirect back to the request's referer, otherwise they are redirected back to the updated cron job.
Webhook
type Webhook struct {
web.Handler
// contains filtered or unexported fields
}
NewWebhook
func NewWebhook(h web.Handler, crypto *crypto.AESGCM) Webhook
Webhook.StoreModel
func (h Webhook) StoreModel(r *http.Request) (*namespace.Webhook, namespace.WebhookForm, error)
Webhook.UpdateModel
func (h Webhook) UpdateModel(r *http.Request) (*namespace.Webhook, namespace.WebhookForm, error)
WebhookAPI
type WebhookAPI struct {
Webhook
// Prefix is the part of the URL under which the API is being served, for
// example "/api".
Prefix string
}
WebhookAPI.Destroy
func (h WebhookAPI) Destroy(w http.ResponseWriter, r *http.Request)
WebhookAPI.Index
func (h WebhookAPI) Index(w http.ResponseWriter, r *http.Request)
WebhookAPI.Show
func (h WebhookAPI) Show(w http.ResponseWriter, r *http.Request)
WebhookAPI.Store
func (h WebhookAPI) Store(w http.ResponseWriter, r *http.Request)
WebhookAPI.Update
func (h WebhookAPI) Update(w http.ResponseWriter, r *http.Request)
WebhookUI
type WebhookUI struct {
Webhook
}
WebhookUI.Create
func (h WebhookUI) Create(w http.ResponseWriter, r *http.Request)
WebhookUI.Delivery
func (h WebhookUI) Delivery(w http.ResponseWriter, r *http.Request)
WebhookUI.Destroy
func (h WebhookUI) Destroy(w http.ResponseWriter, r *http.Request)
WebhookUI.Index
func (h WebhookUI) Index(w http.ResponseWriter, r *http.Request)
WebhookUI.Redeliver
func (h WebhookUI) Redeliver(w http.ResponseWriter, r *http.Request)
WebhookUI.Show
func (h WebhookUI) Show(w http.ResponseWriter, r *http.Request)
WebhookUI.Store
func (h WebhookUI) Store(w http.ResponseWriter, r *http.Request)
WebhookUI.Update
func (h WebhookUI) Update(w http.ResponseWriter, r *http.Request)