Merge pull request #816 from filecoin-project/feat/api-cleanup

Move api struct to a seprate pkg
This commit is contained in:
Łukasz Magiera
2019-12-09 18:33:13 +01:00
committed by GitHub
11 changed files with 101 additions and 93 deletions
-1
View File
@@ -2,7 +2,6 @@ package impl
import (
"context"
"github.com/gbrlsnchs/jwt/v3"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/network"
+2 -1
View File
@@ -3,6 +3,7 @@ package impl
import (
"context"
"encoding/json"
"github.com/filecoin-project/lotus/api/apistruct"
"io"
"mime"
"net/http"
@@ -33,7 +34,7 @@ type StorageMinerAPI struct {
}
func (sm *StorageMinerAPI) ServeRemote(w http.ResponseWriter, r *http.Request) {
if !api.HasPerm(r.Context(), api.PermAdmin) {
if !apistruct.HasPerm(r.Context(), apistruct.PermAdmin) {
w.WriteHeader(401)
json.NewEncoder(w).Encode(struct{ Error string }{"unauthorized: missing write permission"})
return