passed/routes/has_password.go

25 lines
480 B
Go
Raw Permalink Normal View History

package routes
import (
"net/http"
"git.1e99.eu/1e99/passed/storage"
)
func HasPassword(store storage.Store) http.HandlerFunc {
return func(res http.ResponseWriter, req *http.Request) {
id := req.PathValue("id")
2024-10-30 10:17:48 +00:00
_, err := store.Get(id)
switch {
case err == storage.ErrNotFound:
http.Error(res, "", http.StatusNotFound)
return
case err != nil:
http.Error(res, "", http.StatusInternalServerError)
return
}
2024-10-30 10:17:48 +00:00
res.WriteHeader(http.StatusNoContent)
}
}