email kinda working
This commit is contained in:
21
main.go
21
main.go
@@ -40,6 +40,27 @@ func main() {
|
||||
|
||||
publicURL, _ := url.Parse(cfg.Server.PublicURL)
|
||||
|
||||
http.HandleFunc("/respond", func(w http.ResponseWriter, r *http.Request) {
|
||||
p := r.URL.Query().Get("path")
|
||||
attendee := r.URL.Query().Get("attendee")
|
||||
status := r.URL.Query().Get("status")
|
||||
|
||||
if p == "" || attendee == "" || status == "" {
|
||||
http.Error(w, "Missing parameters", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
err := be.RespondToInvitation(r.Context(), p, attendee, status)
|
||||
if err != nil {
|
||||
log.Printf("[email] Error handling response: %v", err)
|
||||
http.Error(w, fmt.Sprintf("Error: %v", err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
fmt.Fprintf(w, "<h1>Response recorded</h1><p>You have %s the invitation for %s.</p>", strings.ToLower(status), attendee)
|
||||
})
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
// Proxy-aware normalization:
|
||||
if publicURL != nil && publicURL.Host != "" {
|
||||
|
||||
Reference in New Issue
Block a user