sprechstunden-go/controllers/confirmRequestHandler.go

26 lines
603 B
Go
Raw Normal View History

package controllers
import (
"net/http"
)
func (b *BaseHandler) ConfirmRequestHandler(w http.ResponseWriter, req *http.Request) {
secret := req.FormValue("code")
request, err := b.requestRepo.FindBySecret(secret)
if err != nil {
w.WriteHeader(http.StatusNotFound)
Templates.ExecuteTemplate(w, "requestNotFound.html", struct{}{})
return
}
err = b.requestRepo.Execute(request)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Templates.ExecuteTemplate(w, "executeFailure.html", err.Error())
2022-09-07 19:48:40 +00:00
return
}
Templates.ExecuteTemplate(w, "executeSuccess.html", struct{}{})
2022-09-07 19:48:40 +00:00
}