handlers

package
v0.0.0-...-73f3dc2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SessionStore = make(map[string]map[string]interface{})

Functions

func CommentHandler

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

func CreatePost

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

UploadMedia handler function is responsible for performing server operations to enable media upload with a file size limit of up to 20 megabytes.

func CreateSession

func CreateSession() string

func DeleteSession

func DeleteSession(userId int)

func EnableCors

func EnableCors(w http.ResponseWriter)

func FilterPosts

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

FilterPosts - Handles filtering posts by category or user

func FormatTimestamp

func FormatTimestamp(w http.ResponseWriter, r *http.Request, db *sql.DB)

FormatTimestamp converts the timestamp in the database to UTC format.

func GetAllPosts

func GetAllPosts(db *sql.DB, tmpl *template.Template, posts []models.Post) http.HandlerFunc

func GetAllPostsAPI

func GetAllPostsAPI(db *sql.DB) http.HandlerFunc

func HandleGetPosts

func HandleGetPosts(w http.ResponseWriter, r *http.Request, db *sql.DB)

func HomeHandler

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

func IndexHandler

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

func LoginHandler

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

func LogoutHandler

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

func PostDetails

func PostDetails(w http.ResponseWriter, r *http.Request, posts []models.Post, logged bool)

func ReactionHandler

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

func SetSessionCookie

func SetSessionCookie(w http.ResponseWriter, sessionID string)

func SetSessionData

func SetSessionData(sessionID string, key string, value interface{})

func SignupHandler

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

func ValidateInputHandler

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

ValidateInputHandler checks if a name or email already exists in the database.

func ValidateMimeType

func ValidateMimeType(file multipart.File) (string, error)

ValidateMimeType is used to check the MIME type of an uploaded file. It returns the extension associated with the file.

Types

type RequestData

type RequestData struct {
	ID string `json:"id"`
}

type Response

type Response struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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