Second rename pass closing the backend cleanup:
* handler functions (handleListProjekte, handleCreateFrist, …) renamed
to English equivalents so every symbol in the handler package matches
the URL/entity it serves.
* services.FristStatusFilter + filter constants renamed to
DeadlineStatusFilter / DeadlineFilterOverdue etc.
* services.TerminListFilter / TerminCalDAVPusher / TerminSummaryCounts
renamed to AppointmentListFilter / AppointmentCalDAVPusher /
AppointmentSummaryCounts.
* GlossarTerm/GlossarSuggestion/glossarTerms → Glossary*.
* CourtsFeedback/CourtsResponse (formerly Gerichte*).
* handlers.Services.{Projekt,Parteien,Frist,Termin,Notiz,Dezernat} →
{Project,Party,Deadline,Appointment,Note,Department}; dbServices
struct + consumers likewise.
* email templates: {{.FristURL}} → {{.DeadlineURL}}, {{.FristenURL}} →
{{.DeadlinesURL}}.
* links.go category IDs: gerichte → courts.
* cmd/server/main.go local vars: projektSvc/terminSvc/dezernatSvc →
projectSvc/appointmentSvc/departmentSvc.
Routes:
* removed all /api/akten alias routes (API clients use /api/projects now).
* removed /api/akten/*/deadlines, /*/notes, /*/parties, /*/appointments,
/*/checklists, /*/events, /*/summary alias variants.
* new internal/handlers/redirects.go registers 301 Moved Permanently
redirects for every legacy German GET path: /akten, /projekte, /fristen,
/termine, /notizen, /einstellungen, /checklisten, /dezernate, /parteien,
/gerichte, /glossar. Sub-paths + query strings are preserved so old
bookmarks keep working.
Kept in German (product names, per task spec):
* /tools/fristenrechner, /tools/kostenrechner, /tools/gebuehrentabellen
* FristenrechnerService / KostenrechnerService types
* User.Dezernat + paliad.users.dezernat free-text legacy column (separate
from the new paliad.departments entity).
go build / vet / test clean.
48 lines
1.6 KiB
Go
48 lines
1.6 KiB
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
// registerLegacyRedirects wires every historical German URL path to its
|
|
// English successor as a 301 Moved Permanently. One entry per legacy prefix;
|
|
// sub-paths are preserved verbatim in the redirect target (e.g.
|
|
// /akten/abc/deadlines → /projects/abc/deadlines).
|
|
//
|
|
// Only GET is redirected — old POST/PATCH/DELETE API endpoints are not
|
|
// mirrored. API clients must update to the English /api/* paths.
|
|
func registerLegacyRedirects(mux *http.ServeMux) {
|
|
// Prefix pairs: when the request path starts with key, it's rewritten to
|
|
// value + whatever followed the key. Order does not matter because each
|
|
// prefix is registered as its own pattern on the mux.
|
|
prefixes := map[string]string{
|
|
"/akten": "/projects",
|
|
"/projekte": "/projects",
|
|
"/fristen": "/deadlines",
|
|
"/termine": "/appointments",
|
|
"/notizen": "/notes",
|
|
"/einstellungen": "/settings",
|
|
"/checklisten": "/checklists",
|
|
"/dezernate": "/departments",
|
|
"/parteien": "/parties",
|
|
"/gerichte": "/courts",
|
|
"/glossar": "/glossary",
|
|
}
|
|
for oldPrefix, newPrefix := range prefixes {
|
|
mux.Handle("GET "+oldPrefix, redirectPrefix(oldPrefix, newPrefix))
|
|
mux.Handle("GET "+oldPrefix+"/", redirectPrefix(oldPrefix, newPrefix))
|
|
}
|
|
}
|
|
|
|
func redirectPrefix(oldPrefix, newPrefix string) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
tail := strings.TrimPrefix(r.URL.Path, oldPrefix)
|
|
target := newPrefix + tail
|
|
if r.URL.RawQuery != "" {
|
|
target += "?" + r.URL.RawQuery
|
|
}
|
|
http.Redirect(w, r, target, http.StatusMovedPermanently)
|
|
})
|
|
}
|