📝 Add docstrings to feat/go-rewrite

Docstrings generation was requested by @blakeridgway.

* https://github.com/RideAware/admin-panel/pull/1#issuecomment-3528008426

The following files were modified:

* `cmd/admin-panel/main.go`
* `internal/config/config.go`
* `internal/database/database.go`
* `internal/email/email.go`
* `internal/handlers/auth.go`
* `internal/handlers/newsletter.go`
* `internal/handlers/subscribers.go`
* `internal/middleware/auth.go`
This commit is contained in:
coderabbitai[bot]
2025-11-13 14:11:06 +00:00
committed by GitHub
parent 899313dcac
commit 2adb7e3605
8 changed files with 69 additions and 0 deletions

View File

@@ -9,10 +9,13 @@ import (
"github.com/gin-gonic/gin"
)
// LoginGet renders the login page using the "login.html" template with HTTP 200 status.
func LoginGet(c *gin.Context) {
c.HTML(http.StatusOK, "login.html", gin.H{})
}
// LoginPost handles POST /login form submissions, authenticates the user, creates a session, and redirects to "/" on success.
// On invalid credentials it renders the login page with HTTP 401 and an error message; if session retrieval or saving fails it aborts with HTTP 500.
func LoginPost(c *gin.Context) {
username := c.PostForm("username")
password := c.PostForm("password")
@@ -39,6 +42,8 @@ func LoginPost(c *gin.Context) {
c.Redirect(http.StatusFound, "/")
}
// Logout invalidates the current user session if one exists and redirects the client to the login page.
// If the session cannot be retrieved, the handler still redirects to "/login".
func Logout(c *gin.Context) {
session, err := middleware.GetStore().Get(c.Request, "session")
if err == nil {

View File

@@ -8,10 +8,15 @@ import (
"github.com/gin-gonic/gin"
)
// SendUpdateGet renders the update form page using the "send_update.html" template and responds with HTTP 200 OK.
func SendUpdateGet(c *gin.Context) {
c.HTML(http.StatusOK, "send_update.html", gin.H{})
}
// SendUpdatePost handles POST requests to submit a newsletter update.
// It reads "subject" and "body" from the form, calls email.SendUpdate(subject, body),
// and renders the "send_update.html" template with gin.H{"error": message} when sending fails
// or gin.H{"success": message} when sending succeeds, returning HTTP 200 in both cases.
func SendUpdatePost(c *gin.Context) {
subject := c.PostForm("subject")
body := c.PostForm("body")

View File

@@ -8,6 +8,9 @@ import (
"github.com/gin-gonic/gin"
)
// IndexGet handles requests for the admin index page by retrieving all subscriber emails
// and rendering the "admin_index.html" template with those emails.
// If retrieving emails fails, it aborts the request with HTTP 500 and the error.
func IndexGet(c *gin.Context) {
emails, err := database.GetAllEmails()
if err != nil {