passed/route/has_password.go
2025-05-21 17:15:55 +02:00

24 lines
488 B
Go

package route
import (
"net/http"
"git.1e99.eu/1e99/passed/password"
)
func HasPassword(storage password.Storage) http.HandlerFunc {
return func(res http.ResponseWriter, req *http.Request) {
id := req.PathValue("id")
_, err := storage.Get(id)
switch {
case err == password.ErrNotFound:
http.Error(res, "", http.StatusNotFound)
return
case err != nil:
http.Error(res, "", http.StatusInternalServerError)
return
}
res.WriteHeader(http.StatusNoContent)
}
}