v1

package
v0.0.0-...-95711e6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

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 NewAPI

func NewAPI(db *database.DB, log *waterlog.WaterLog, imagesDir, resourcesDir string) *API

NewAPI creates a new v1 API.

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) Routes

func (a API) Routes() http.Handler

Routes sets up our API routes.

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.

func (API) Upload

func (a API) Upload(w http.ResponseWriter, r *http.Request)

Upload handles requests to upload files to the server.

type AddUserRequest

type AddUserRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

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

type HTTPError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

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.

Jump to

Keyboard shortcuts

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