25 lines
460 B
Go
25 lines
460 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")
|
||
|
found, err := store.HasPassword(id)
|
||
|
if err != nil {
|
||
|
http.Error(res, "", http.StatusInternalServerError)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if found {
|
||
|
res.WriteHeader(http.StatusNoContent)
|
||
|
} else {
|
||
|
res.WriteHeader(http.StatusNotFound)
|
||
|
}
|
||
|
}
|
||
|
}
|