24 lines
480 B
Go
24 lines
480 B
Go
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")
|
|
_, err := store.Get(id)
|
|
switch {
|
|
case err == storage.ErrNotFound:
|
|
http.Error(res, "", http.StatusNotFound)
|
|
return
|
|
case err != nil:
|
|
http.Error(res, "", http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
res.WriteHeader(http.StatusNoContent)
|
|
}
|
|
}
|