controllers

package
v0.0.0-...-37a27fb Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateComment

func CreateComment(w http.ResponseWriter, r *http.Request)

CreateComment adds new comment record to database.

Returns Comment model on success

func CreatePost

func CreatePost(w http.ResponseWriter, r *http.Request)

CreatePost adds new post record to database

Returns Post model on success

func DeleteComment

func DeleteComment(w http.ResponseWriter, r *http.Request)

DeleteComment removes comment and all it's reactions records from database

func DeletePost

func DeletePost(w http.ResponseWriter, r *http.Request)

DeletePost removes records: post, it's reactions, it's categories, comments realted to that post and reactions to these comments from database

func DeleteUser

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

DeleteUser deletes a user from the database TODO delte all reactions of deleted user

func FindComments

func FindComments(w http.ResponseWriter, r *http.Request)

FindComments allows to search comments by various parameters. Currently supported:

- author - returns all comments from single user

func FindPost

func FindPost(w http.ResponseWriter, r *http.Request)

FindPost allows to search posts by various parameters. Currently supported:

- id - returns a post with that id

- author - returns all posts from single user

- categories - returns posts that have theese categories

func FindUser

func FindUser(w http.ResponseWriter, r *http.Request)

FindUser allows to search user by various parameters. Currently supported:

- id - returns a user with that id

func GetAllCategories

func GetAllCategories(w http.ResponseWriter, r *http.Request)

GetAllCategories returns categories for all posts as an array

func GetComments

func GetComments(w http.ResponseWriter, r *http.Request)

GetComments returns all comments for a single post as an array

func GetPosts

func GetPosts(w http.ResponseWriter, r *http.Request)

GetPosts returns struct with fields:

- hot - several posts, sorted by their rating

- recent - several posts sorted by date

- total_rows - total amount of rows in posts table. Used for pagination component on frontend

func GetUsers

func GetUsers(w http.ResponseWriter, r *http.Request)

GetUsers returns all user records from database as an array

func LogOut

func LogOut(w http.ResponseWriter, r *http.Request)

LogOut deletes user session id from database and destroys session cookie in his browser

func Me

func Me(w http.ResponseWriter, r *http.Request)

Me function returns a user with an id from request context

func OAuthHandler

func OAuthHandler(w http.ResponseWriter, r *http.Request)

func RateComment

func RateComment(w http.ResponseWriter, r *http.Request)

RateComment adds / removes / modifies user reaction for comment, depending on his previous reaction to that comment

func RatePost

func RatePost(w http.ResponseWriter, r *http.Request)

RatePost adds / removes / modifies user reaction for post, depending on his previous reaction to that post

func SendVerification

func SendVerification(w http.ResponseWriter, r *http.Request)

func ServeImage

func ServeImage(w http.ResponseWriter, r *http.Request)

func SignIn

func SignIn(w http.ResponseWriter, r *http.Request)

SignIn verifies user credinentials with database.

Returns User model on success

func SignUp

func SignUp(w http.ResponseWriter, r *http.Request)

SignUp creates new user record in database

Returns User model on success

func UpdateComment

func UpdateComment(w http.ResponseWriter, r *http.Request)

UpdateComment modifies comment record in database with new data

Returns Comment model on success

func UpdatePost

func UpdatePost(w http.ResponseWriter, r *http.Request)

UpdatePost modifies post record in database

Returns Post model on success

func UpdateUser

func UpdateUser(w http.ResponseWriter, r *http.Request)

UpdateUser modifies user record in database

func UploadImage

func UploadImage(w http.ResponseWriter, r *http.Request)

func VerifyEmail

func VerifyEmail(w http.ResponseWriter, r *http.Request)

Types

This section is empty.

Jump to

Keyboard shortcuts

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