sprechstunden-go/controllers/confirmRequestHandler.go

27 lines
597 B
Go
Raw Normal View History

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