feat(http): add imprint url

This commit is contained in:
2026-06-24 11:37:20 +02:00
parent 748b83f4a0
commit 959a4edc32
2 changed files with 17 additions and 5 deletions
+4 -1
View File
@@ -13,6 +13,7 @@ var config pq.Config
var (
oidcIssuer, oidcClientID, oidcClientSecret, oidcRedirectURI string
jwtSigningKey string
imprintURL string
)
func main() {
@@ -26,7 +27,7 @@ func main() {
panic(err)
}
if err := http.Start(); err != nil {
if err := http.Start(imprintURL); err != nil {
panic(err)
}
@@ -47,5 +48,7 @@ func handleflag() {
flag.StringVar(&jwtSigningKey, "signingKey", "UNSAFE", "The JWT signingkey")
flag.StringVar(&imprintURL, "imprinturl", "", "The URL to the sites imprint")
flag.Parse()
}
+13 -4
View File
@@ -3,16 +3,14 @@ package http
import (
"net/http"
assets "tomatentum.net/outfit-voting-abi26"
"tomatentum.net/outfit-voting-abi26/internal/auth"
"tomatentum.net/outfit-voting-abi26/internal/http/vote"
)
var mux *http.ServeMux = http.NewServeMux()
func Start() error {
mux.Handle("/", auth.AuthMiddleware(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
}))
func Start(imprintURL string) error {
mux.HandleFunc("/api/auth/logout", auth.LogoutEndpoint)
mux.HandleFunc("GET /api/vote/locked", vote.VoteLockedEndpoint)
@@ -31,6 +29,17 @@ func Start() error {
mux.Handle("POST /api/vote", auth.AuthMiddleware(vote.AddVoteEntryEndpoint))
mux.Handle("POST /api/vote/bulk", auth.AuthMiddleware(vote.BulkVoteEntryEndpoint))
mux.HandleFunc("/impressum", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, imprintURL, http.StatusFound)
})
mux.Handle("/", assets.HttpServer())
mux.Handle("/admin", auth.AuthMiddleware(assets.ServeIndex))
mux.HandleFunc("/result", assets.ServeIndex)
mux.HandleFunc("/account", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, auth.IssuerBaseURL(), http.StatusFound)
})
auth.CallbackHandler(mux)
return http.ListenAndServe(":4000", corsMiddleware(mux))
}