refactor: cleanup db helpers, ratelimit and base template padding

This commit is contained in:
2026-05-12 12:34:42 +02:00
parent 5d55edf9b8
commit 459e4d30b3
3 changed files with 1 additions and 20 deletions

View File

@@ -24,14 +24,6 @@ func (r GetUserWatchListRow) DisplayTitle() string {
return DisplayTitle(r.TitleEnglish, r.TitleJapanese, r.TitleOriginal)
}
// BoolPtr converts a nullable bool to a pointer; nil if not valid
func BoolPtr(b sql.NullBool) *bool {
if !b.Valid {
return nil
}
return &b.Bool
}
// BeginTx starts a transaction and returns the Queries wrapper bound to it
func BeginTx(ctx context.Context, db *sql.DB) (*Queries, *sql.Tx, error) {
if db == nil {

View File

@@ -61,17 +61,6 @@ func getIP(r *http.Request) string {
return ip
}
// Middleware returns 429 for rate-limited API requests
func (l *Limiter) Middleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !l.allow(getIP(r)) {
http.Error(w, "Too many requests. Please try again later.", http.StatusTooManyRequests)
return
}
next.ServeHTTP(w, r)
})
}
// AuthMiddleware redirects rate-limited form submissions back to the page
// returns 429 for non-path requests (e.g. API calls)
func (l *Limiter) AuthMiddleware(next http.Handler) http.Handler {

View File

@@ -205,7 +205,7 @@ if (window.showToast) showToast({ message: 'Something went wrong' })
<div class="sticky top-0 z-40 w-full">
{{template "header" .}}
</div>
<div class="flex-1 p-4 md:p-8 lg:p-12">
<div class="flex-1 p-4 md:p-8 lg:p-10">
{{template "content" .}}
</div>
{{template "footer" .}}