handler
v1.1.1
Documentation
pkg.go.dev ↗Types
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.
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.
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.
API.Show
func (h API) Show(w http.ResponseWriter, r *http.Request)
Show serves the JSON response for viewing an individual variable.
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.
UI
type UI struct {
Variable
}
UI is the handler for handling UI requests made for variable creation, and management.
UI.Create
func (h UI) Create(w http.ResponseWriter, r *http.Request)
Create serves the HTML response for creating variables via the web frontend.
UI.Index
func (h UI) Index(w http.ResponseWriter, r *http.Request)
Index serves the HTML response detailing the list of variables.
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.
New
func New(h web.Handler) Variable
Variable.DeleteModel
func (h Variable) DeleteModel(r *http.Request) error
DeleteModel removes the variable in the given request context from the database.
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.
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.
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.
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.