Documentation ¶
Index ¶
- type API
- type Image
- func (h Image) Create(w http.ResponseWriter, r *http.Request)
- func (h Image) DeleteModel(r *http.Request) error
- func (h Image) Destroy(w http.ResponseWriter, r *http.Request)
- func (h Image) Index(w http.ResponseWriter, r *http.Request)
- func (h Image) IndexWithRelations(r *http.Request) ([]*image.Image, database.Paginator, error)
- func (h Image) Show(w http.ResponseWriter, r *http.Request)
- func (h Image) ShowWithRelations(r *http.Request) (*image.Image, error)
- func (h Image) Store(w http.ResponseWriter, r *http.Request)
- func (h Image) StoreModel(w http.ResponseWriter, r *http.Request) (*image.Image, image.Form, error)
- type UI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { Image // 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 image in the given request context from the database and underlying block store. 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 images for the given request. If multiple pages of images are returned then the database.Paginator is encoded in the Link response header.
type Image ¶
Image is the base handler that provides shared logic for the UI and API handlers for image creation, and management.
func (Image) Create ¶
func (h Image) Create(w http.ResponseWriter, r *http.Request)
Create serves the HTML response for creating and uploading images via the web frontend.
func (Image) DeleteModel ¶
DeleteModel removes the image in the given request context from the database and the underlying block store.
func (Image) Destroy ¶
func (h Image) Destroy(w http.ResponseWriter, r *http.Request)
Destroy removes the image in the given request context from the database. This redirects back to the image index if this was done from an individual image view, otherwise it redirects back to the request's referer.
func (Image) Index ¶
func (h Image) Index(w http.ResponseWriter, r *http.Request)
Index serves the HTML response detailing the list of images.
func (Image) IndexWithRelations ¶
IndexWithRelations retrieves a slice of *image.Image models for the user in the given request context. All of the relations for each image will be loaded into each model we have. If any of the images 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 images.
func (Image) Show ¶
func (h Image) Show(w http.ResponseWriter, r *http.Request)
Show serves the HTML response for viewing an individual image in the given request.
func (Image) ShowWithRelations ¶
ShowWithRelations retrieves the *image.Image model from the context of the given request. All of the relations for the image will be loaded into the model we have. If the image has a namespace bound to it, then the namespace's user will be loaded to the namespace.
func (Image) Store ¶
func (h Image) Store(w http.ResponseWriter, r *http.Request)
Store validates the form submitted in the given request for creating an image. If validation fails then the user is redirected back to the request referer, otherwise they are redirect back to the image index.
func (Image) StoreModel ¶
StoreModel unmarshals the request's data into an image, validates it and stores it in the database. Upon success this will return the newly created image. This also returns the form for creating an image.