2024-10-29 23:36:53 +00:00
|
|
|
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:
|
2024-10-29 23:36:53 +00:00
|
|
|
http.Error(res, "", http.StatusInternalServerError)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-10-30 10:17:48 +00:00
|
|
|
res.WriteHeader(http.StatusNoContent)
|
2024-10-29 23:36:53 +00:00
|
|
|
}
|
|
|
|
}
|