feat(http): add imprint url
This commit is contained in:
+4
-1
@@ -13,6 +13,7 @@ var config pq.Config
|
|||||||
var (
|
var (
|
||||||
oidcIssuer, oidcClientID, oidcClientSecret, oidcRedirectURI string
|
oidcIssuer, oidcClientID, oidcClientSecret, oidcRedirectURI string
|
||||||
jwtSigningKey string
|
jwtSigningKey string
|
||||||
|
imprintURL string
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -26,7 +27,7 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := http.Start(); err != nil {
|
if err := http.Start(imprintURL); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,5 +48,7 @@ func handleflag() {
|
|||||||
|
|
||||||
flag.StringVar(&jwtSigningKey, "signingKey", "UNSAFE", "The JWT signingkey")
|
flag.StringVar(&jwtSigningKey, "signingKey", "UNSAFE", "The JWT signingkey")
|
||||||
|
|
||||||
|
flag.StringVar(&imprintURL, "imprinturl", "", "The URL to the sites imprint")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-4
@@ -3,16 +3,14 @@ package http
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
assets "tomatentum.net/outfit-voting-abi26"
|
||||||
"tomatentum.net/outfit-voting-abi26/internal/auth"
|
"tomatentum.net/outfit-voting-abi26/internal/auth"
|
||||||
"tomatentum.net/outfit-voting-abi26/internal/http/vote"
|
"tomatentum.net/outfit-voting-abi26/internal/http/vote"
|
||||||
)
|
)
|
||||||
|
|
||||||
var mux *http.ServeMux = http.NewServeMux()
|
var mux *http.ServeMux = http.NewServeMux()
|
||||||
|
|
||||||
func Start() error {
|
func Start(imprintURL string) error {
|
||||||
mux.Handle("/", auth.AuthMiddleware(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
}))
|
|
||||||
mux.HandleFunc("/api/auth/logout", auth.LogoutEndpoint)
|
mux.HandleFunc("/api/auth/logout", auth.LogoutEndpoint)
|
||||||
|
|
||||||
mux.HandleFunc("GET /api/vote/locked", vote.VoteLockedEndpoint)
|
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", auth.AuthMiddleware(vote.AddVoteEntryEndpoint))
|
||||||
mux.Handle("POST /api/vote/bulk", auth.AuthMiddleware(vote.BulkVoteEntryEndpoint))
|
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)
|
auth.CallbackHandler(mux)
|
||||||
return http.ListenAndServe(":4000", corsMiddleware(mux))
|
return http.ListenAndServe(":4000", corsMiddleware(mux))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user