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: 12 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 {
	Variable

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

func (API) Destroy

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

Destroy removes the variable 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 variables for the given request. If multiple pages of variables are returned then the database.Paginator is encoded in the Link response header.

func (API) Show added in v1.1.0

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

Show serves the JSON response for viewing an individual variable.

func (API) Store

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

Store stores and submits the variable from the given request body. If any validation errors occur then these will be sent back in the JSON response. On success the variable is sent in the JSON response.

type UI

type UI struct {
	Variable
}

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

func (UI) Create

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

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

func (UI) Index

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

Index serves the HTML response detailing the list of variables.

type Variable

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

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

func New

func New(h web.Handler) Variable

func (Variable) DeleteModel

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

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

func (Variable) Destroy

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

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

func (Variable) IndexWithRelations

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

IndexWithRelations retrieves a slice of *variable.Variable models for the user in the given request context. All of the relations for each variable 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 variables.

func (Variable) Store

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

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

func (Variable) StoreModel

func (h Variable) StoreModel(r *http.Request) (*variable.Variable, variable.Form, error)

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

Jump to

Keyboard shortcuts

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