Verbessere Dokumentation
This commit is contained in:
parent
ec24c6c4dc
commit
fe54d76ab2
14 changed files with 75 additions and 34 deletions
|
@ -1,19 +1,27 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"net/http"
|
||||
"officeHours/templating"
|
||||
)
|
||||
|
||||
// Check the secret token for requests and execute the request for correct tokens
|
||||
func (b *BaseHandler) ConfirmRequestHandler(w http.ResponseWriter, req *http.Request) {
|
||||
secret := req.FormValue("code")
|
||||
request, err := b.requestRepo.FindBySecret(secret)
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) { // There was no request with this secret
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
templating.ServeTemplate(w, "requestNotFound", nil)
|
||||
return
|
||||
}
|
||||
if err != nil { // Some other error happened finding the request with this secret
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
templating.ServeTemplate(w, "executeFailure", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = b.requestRepo.Execute(request)
|
||||
if err != nil {
|
||||
|
@ -22,5 +30,4 @@ func (b *BaseHandler) ConfirmRequestHandler(w http.ResponseWriter, req *http.Req
|
|||
return
|
||||
}
|
||||
templating.ServeTemplate(w, "executeSuccess", nil)
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue