Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

handler

v1.1.1
djinn-ci.com/key/handler

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

21 matches

Top ↑

Types

API

type API struct {
	Key

	// 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 key creation, and management.

API.Destroy

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

Destroy removes the key 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 keys for the given request. If multiple pages of keys 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 the JSON response for viewing an individual key.

API.Store

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

Store stores and submits the key from the given request body. If any validation errors occur then these will be sent back in the JSON response. On success the key 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 key in the database. If any validation errors occur then these will be sent back in the JSON response. On success the updated key is sent in the JSON response.

Key

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

Key is the base handler that provides shared logic for the UI and API handlers for key creation, and management.

New

func New(h web.Handler, block *crypto.AESGCM) Key

Key.Create

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

Create serves the HTML response for creating SSH keys via the web frontend.

Key.DeleteModel

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

DeleteModel removes the key in the given request context from the database.

Key.Destroy

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

Destroy removes the key in the given request context from the database. This redirects back to the request's referer.

Key.Edit

func (h Key) Edit(w http.ResponseWriter, r *http.Request)

Edit serves the HTML response for editing the key in the given request context.

Key.Index

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

Index serves the HTML response detailing the list of SSH keys.

Key.IndexWithRelations

func (h Key) IndexWithRelations(r *http.Request) ([]*key.Key, database.Paginator, error)

IndexWithRelations retrieves a slice of *key.Key models for the user in the given request context. All of the relations for each key will be loaded into each model we have. If any of the keys have a bound namespace, then the namespace's user will be loaded too. A database.Paginator will also be returned if there are multiple pages of keys.

Key.ShowWithRelations

func (h Key) ShowWithRelations(r *http.Request) (*key.Key, error)

ShowWithRelations retrieves the *key.Keys model from the context of the given request. All of the relations for the key will be loaded into the model we have. If the key has a namespace bound to it, then the namespace's user will be loaded to the namespace.

Key.Store

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

Store validates the form submitted in the given request for creating a key. If validation fails then the user is redirected back to the request referer, otherwise they are redirect back to the key index.

Key.StoreModel

func (h Key) StoreModel(r *http.Request) (*key.Key, key.Form, error)

StoreModel unmarshals the request's data into a key, validates it and stores it in the database. Upon success this will return the newly created key. This also returns the form for creating a key.

Key.Update

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

Update validates the form submitted in the given request for updating a key. If validation fails then the user is redirect back to the request's referer, otherwise they are redirected back to the updated cron job.

Key.UpdateModel

func (h Key) UpdateModel(r *http.Request) (*key.Key, key.Form, error)

UpdateModel unmarshals the request's data into a key, validates it and updates the existing key in the database with the content in the form. Upon success the updated key is returned. This also returns the form for modifying a key.

UI

type UI struct {
	Key
}

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

Dependency graph