web

package
v0.0.0-...-0daaea0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSharedFile

func CreateSharedFile(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

CreateSharedFile handles the request to create a shared file instance.

func DeleteFile

func DeleteFile(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

DeleteFile is a handler that deletes a file owned by the user. The handler takes a file id as a query parameter and then does checking on the ownership of the file. Also the route is protected, so that the security token is checked before calling this handler.

func DeleteSharedContract

func DeleteSharedContract(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

DeleteSharedContract removes a given shared contract by the users. It takes in the type of contract from the type query parameter and the file in question from the file query parameter.

func DeleteUser

func DeleteUser(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

DeleteUser handles a total account deletion that includes deleting all information about the user and his/her files. Also deletes the user's token so that user can't make requests with a invalid username that doesn't exist.

func DownloadFile

func DownloadFile(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

DownloadFile handler lets the user download a file. It also checks that the user owns the file he is trying download. Also the route is protected, so that the security token is checked before calling this handler.

func ErrorPageHandler

func ErrorPageHandler(w http.ResponseWriter, r *http.Request,
	errorType lib.ErrorPageContent)

ErrorPageHandler takes in a request context and a error type which is then used in a template to dynamically display an error page.

func GetSharedByUser

func GetSharedByUser(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

GetSharedByUser returns all of the files the user has shared. The user can either download the files from this page. Or they can remove the file sharing.

func GetSharedToUser

func GetSharedToUser(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

GetSharedToUser returns all of the files shared to the user requesting this handler. he can also delete shared files from this page.

func GetSingleFile

func GetSingleFile(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

GetSingleFile returns the database entry, which contains data about a file to the user. The user needs to provide a file id as a query. Also the files are kept private, so you need to own the file. Also the route is protected, so that the security token is checked before calling this handler.

func GetUserFiles

func GetUserFiles(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

GetUserFiles returns all the files that are related to the username which is requesting this handler. Then handler finds all the related files and constructs a template, which the user then can view as html content. Also the route is protected, so that the security token is checked before calling this handler.

func HandleSettingChange

func HandleSettingChange(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

HandleSettingChange applies the new settings to the new user's database entry. This handler will get called by the ServeSettingsPage handler's html template.

func Login

Login handles the login request from the /login page. It firstly checks that the a user with the given username does exist and then checks that user's hash using bcrypt to the password given in the form.

func Register

func Register(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

Register handles the register request from the /register page html form. It creates checks for conflicting usernames and creates a folder to the store all of the user's files in. Finally it creates a database entry with all the information in given in the form.

func ServeCreateSharedPage

func ServeCreateSharedPage(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

ServeCreateSharedPage just renders the template containing the share page.

func ServeHomePage

func ServeHomePage(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

ServeHomePage just sends the user the home.html file which contains some information about the service.

func ServeLoginPage

func ServeLoginPage(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

ServeLoginPage returns the login html page to the user.

func ServeRegisterPage

func ServeRegisterPage(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

ServeRegisterPage returns the register html page to the user.

func ServeSettingsPage

func ServeSettingsPage(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

ServeSettingsPage serves the user a settings page, in which they can configure their account settings. Also does checking if the user is logged in. After all the checking serve a html template, which is used to display current user configuration.

func ServeUploadPage

func ServeUploadPage(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

ServeUploadPage serves the requester a upload form, in which the user can upload files to their account. Also the route is protected, so that the security token is checked before calling this handler.

func StartServer

func StartServer(port string)

func UpdateFile

func UpdateFile(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

UpdateFile is http handler which takes a file id as a query parameter and checks for the file's ownership. This handler can be used to update file title and description. Also the route is protected, so that the security token is checked before calling this handler.

func UpdatePassword

func UpdatePassword(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

UpdatePassword handles the update of a user's password given a new password and the old password. Also does checking if the current password provided is matching, if not the password won't be updated.

func UploadFile

func UploadFile(w http.ResponseWriter, r *http.Request, _ httprouter.Params)

Types

This section is empty.

Jump to

Keyboard shortcuts

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