handler

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type 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.

func (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.

func (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.

func (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.

func (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.

func (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.

type 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.

func (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.

type 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.

func (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.

func (CollaboratorAPI) Index

Index serves the JSON encoded list of collaborators for the given request.

type CollaboratorUI

type CollaboratorUI struct {
	Collaborator
}

CollaboratorUI is the handler for handling UI requests made for managing namespace collaborators.

func (CollaboratorUI) Destroy

func (h CollaboratorUI) Destroy(w http.ResponseWriter, r *http.Request)

Destroy removes the given namespace collaborator in the request from the namespace.

func (CollaboratorUI) Index

Index serves the HTML response detailing the list of namespace collaborators.

type 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.

func NewInvite

func NewInvite(h web.Handler) Invite

func (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.

func (Invite) DeleteModel

func (h Invite) DeleteModel(r *http.Request) error

DeleteModel deletes the namespace invite in the given request context from the database.

func (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.

func (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.

type 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.

func (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.

func (InviteAPI) Index

func (h InviteAPI) Index(w http.ResponseWriter, r *http.Request)

Index serves the JSON encoded list of invites for the given request.

func (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.

func (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.

type InviteUI

type InviteUI struct {
	Invite
}

InviteUI is the handler for handling UI requests made for sending and receiving namespace invites.

func (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.

func (InviteUI) Index

func (h InviteUI) Index(w http.ResponseWriter, r *http.Request)

Index serves the HTML response detailing the list of namespace invites.

func (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.

func (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.

type 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.

func New

func New(h web.Handler) Namespace

func (Namespace) Create

func (h Namespace) Create(w http.ResponseWriter, r *http.Request)

Create serves the HTML response for creating namespaces via the web frontend.

func (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.

func (Namespace) Index

func (h Namespace) Index(w http.ResponseWriter, r *http.Request)

Index serves the HTML response detailing the list of namespaces.

func (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.

func (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.

func (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.

func (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.

func (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.

type UI

type UI struct {
	Namespace
}

UI is the handler for handling UI requests made for namespace creation, and management.

func (UI) Badge added in v1.1.0

func (h UI) Badge(w http.ResponseWriter, r *http.Request)

Badge renders an SVG badge of the latest build in the namespace, if any.

func (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.

func (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.

func (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.

type Webhook added in v1.1.0

type Webhook struct {
	web.Handler
	// contains filtered or unexported fields
}

func NewWebhook added in v1.1.0

func NewWebhook(h web.Handler, crypto *crypto.AESGCM) Webhook

func (Webhook) StoreModel added in v1.1.0

func (Webhook) UpdateModel added in v1.1.0

type WebhookAPI added in v1.1.0

type WebhookAPI struct {
	Webhook

	// Prefix is the part of the URL under which the API is being served, for
	// example "/api".
	Prefix string
}

func (WebhookAPI) Destroy added in v1.1.0

func (h WebhookAPI) Destroy(w http.ResponseWriter, r *http.Request)

func (WebhookAPI) Index added in v1.1.0

func (h WebhookAPI) Index(w http.ResponseWriter, r *http.Request)

func (WebhookAPI) Show added in v1.1.0

func (h WebhookAPI) Show(w http.ResponseWriter, r *http.Request)

func (WebhookAPI) Store added in v1.1.0

func (h WebhookAPI) Store(w http.ResponseWriter, r *http.Request)

func (WebhookAPI) Update added in v1.1.0

func (h WebhookAPI) Update(w http.ResponseWriter, r *http.Request)

type WebhookUI added in v1.1.0

type WebhookUI struct {
	Webhook
}

func (WebhookUI) Create added in v1.1.0

func (h WebhookUI) Create(w http.ResponseWriter, r *http.Request)

func (WebhookUI) Delivery added in v1.1.0

func (h WebhookUI) Delivery(w http.ResponseWriter, r *http.Request)

func (WebhookUI) Destroy added in v1.1.0

func (h WebhookUI) Destroy(w http.ResponseWriter, r *http.Request)

func (WebhookUI) Index added in v1.1.0

func (h WebhookUI) Index(w http.ResponseWriter, r *http.Request)

func (WebhookUI) Redeliver added in v1.1.0

func (h WebhookUI) Redeliver(w http.ResponseWriter, r *http.Request)

func (WebhookUI) Show added in v1.1.0

func (h WebhookUI) Show(w http.ResponseWriter, r *http.Request)

func (WebhookUI) Store added in v1.1.0

func (h WebhookUI) Store(w http.ResponseWriter, r *http.Request)

func (WebhookUI) Update added in v1.1.0

func (h WebhookUI) Update(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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