Documentation ¶
Index ¶
- func WriteError(w http.ResponseWriter, message string, code int)
- type API
- func (a API) AddGalleryItem(w http.ResponseWriter, r *http.Request)
- func (a API) AddImages(w http.ResponseWriter, r *http.Request)
- func (a API) AddPhotos(w http.ResponseWriter, r *http.Request)
- func (a API) AddUser(w http.ResponseWriter, r *http.Request)
- func (a API) ChangeThumbnail(w http.ResponseWriter, r *http.Request)
- func (a API) CheckSession(w http.ResponseWriter, r *http.Request)
- func (a API) GetAbout(w http.ResponseWriter, r *http.Request)
- func (a API) GetGalleryItems(w http.ResponseWriter, r *http.Request)
- func (a API) GetPhotos(w http.ResponseWriter, r *http.Request)
- func (a API) GetProject(w http.ResponseWriter, r *http.Request)
- func (a API) GetUsers(w http.ResponseWriter, r *http.Request)
- func (a API) PerformLogin(w http.ResponseWriter, r *http.Request)
- func (a API) PerformLogout(w http.ResponseWriter, r *http.Request)
- func (a API) RemoveGalleryItem(w http.ResponseWriter, r *http.Request)
- func (a API) RemovePhotos(w http.ResponseWriter, r *http.Request)
- func (a API) RemoveProjectImages(w http.ResponseWriter, r *http.Request)
- func (a API) RemoveUser(w http.ResponseWriter, r *http.Request)
- func (a API) Routes() http.Handler
- func (a API) UpdateAbout(w http.ResponseWriter, r *http.Request)
- func (a API) UpdateProject(w http.ResponseWriter, r *http.Request)
- func (a API) Upload(w http.ResponseWriter, r *http.Request)
- type AddUserRequest
- type ChangeThumbnailRequest
- type CheckSessionResponse
- type HTTPError
- type LoginRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteError ¶
func WriteError(w http.ResponseWriter, message string, code int)
WriteError writes an error struct to a ResponseWriter as JSON.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is our v1 API that serves and handles endpoints.
func (API) AddGalleryItem ¶
func (a API) AddGalleryItem(w http.ResponseWriter, r *http.Request)
AddGalleryItem handles a request to add a new gallery item.
Requires a valid auth token.
func (API) AddImages ¶
func (a API) AddImages(w http.ResponseWriter, r *http.Request)
AddImages handles requests to add images to a project.
func (API) AddPhotos ¶
func (a API) AddPhotos(w http.ResponseWriter, r *http.Request)
AddPhotos handles a request to add images to the photography database.
func (API) AddUser ¶
func (a API) AddUser(w http.ResponseWriter, r *http.Request)
AddUser adds a new user into the database.
func (API) ChangeThumbnail ¶
func (a API) ChangeThumbnail(w http.ResponseWriter, r *http.Request)
ChangeThumbnail handles requests to change a thumbnail for a project.
func (API) CheckSession ¶
func (a API) CheckSession(w http.ResponseWriter, r *http.Request)
CheckSession checks if the request has a valid session.
func (API) GetAbout ¶
func (a API) GetAbout(w http.ResponseWriter, r *http.Request)
GetAbout fetches the about page info from a file and sends it to the client.
func (API) GetGalleryItems ¶
func (a API) GetGalleryItems(w http.ResponseWriter, r *http.Request)
GetGalleryItems handles a request to get all gallery items from the database.
func (API) GetPhotos ¶
func (a API) GetPhotos(w http.ResponseWriter, r *http.Request)
GetPhotos handles requests to get all photos from the database.
func (API) GetProject ¶
func (a API) GetProject(w http.ResponseWriter, r *http.Request)
GetProject handles a request to get a portfolio project from the database.
func (API) GetUsers ¶
func (a API) GetUsers(w http.ResponseWriter, r *http.Request)
GetUsers gets all of the users from the database.
func (API) PerformLogin ¶
func (a API) PerformLogin(w http.ResponseWriter, r *http.Request)
PerformLogin checks if the given credentials match, and if so, generates and responds with an auth token.
func (API) PerformLogout ¶
func (a API) PerformLogout(w http.ResponseWriter, r *http.Request)
PerformLogout handles when a user wants to log out of their session.
func (API) RemoveGalleryItem ¶
func (a API) RemoveGalleryItem(w http.ResponseWriter, r *http.Request)
RemoveGalleryItem handles a request to remove a gallery item.
Requires a valid auth token.
func (API) RemovePhotos ¶
func (a API) RemovePhotos(w http.ResponseWriter, r *http.Request)
RemovePhotos handles a request to remove a list of files from the photos database.
It requires a valid auth token.
func (API) RemoveProjectImages ¶
func (a API) RemoveProjectImages(w http.ResponseWriter, r *http.Request)
RemoveProjectImages deletes images for a portfolio project and removes them from the database.
func (API) RemoveUser ¶
func (a API) RemoveUser(w http.ResponseWriter, r *http.Request)
RemoveUser deletes a user from the database, and invalidates any active sessions that the user had.
func (API) UpdateAbout ¶
func (a API) UpdateAbout(w http.ResponseWriter, r *http.Request)
UpdateAbout updates the about page info with new values.
func (API) UpdateProject ¶
func (a API) UpdateProject(w http.ResponseWriter, r *http.Request)
UpdateProject handles requests to update a portfolio project.
type AddUserRequest ¶
AddUserRequest is the username and password to create a new user with.
type ChangeThumbnailRequest ¶
type ChangeThumbnailRequest struct {
Thumbnail string `json:"thumbnail"`
}
ChangeThumbnailRequest holds the file name of the thumbnail to update a project with.
type CheckSessionResponse ¶
type CheckSessionResponse struct {
Valid bool `json:"valid"`
}
CheckSessionResponse is sent when a client is trying to check if they have a valid session.
type HTTPError ¶
HTTPError holds information about an error that will be sent to the client in an HTTP response.
type LoginRequest ¶
type LoginRequest struct { Username string `json:"username"` Password string `json:"password"` Extended bool `json:"extended,omitempty"` }
LoginRequest is the username and password expected from the login endpoint.