Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
Fix review comments by Janos
Browse files Browse the repository at this point in the history
  • Loading branch information
jmozah committed Aug 8, 2019
1 parent e002aae commit 055ed27
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
20 changes: 10 additions & 10 deletions api/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,6 @@ func NewServer(api *api.API, pinAPI *pin.API, corsString string) *Server {
defaultMiddlewares...,
),
})
mux.Handle("/", methodHandler{
"GET": Adapt(
http.HandlerFunc(server.HandleRootPaths),
SetRequestID,
InitLoggingResponseWriter,
),
})
mux.Handle("/bzz-pin:/", methodHandler{
"GET": Adapt(
http.HandlerFunc(server.HandleGetPins),
Expand All @@ -189,6 +182,13 @@ func NewServer(api *api.API, pinAPI *pin.API, corsString string) *Server {
defaultMiddlewares...,
),
})
mux.Handle("/", methodHandler{
"GET": Adapt(
http.HandlerFunc(server.HandleRootPaths),
SetRequestID,
InitLoggingResponseWriter,
),
})
server.Handler = c.Handler(mux)

return server
Expand Down Expand Up @@ -930,10 +930,10 @@ func (s *Server) HandlePin(w http.ResponseWriter, r *http.Request) {
return
}

isRaw := true
isRaw := false
isRawString := r.URL.Query().Get("IsRaw")
if isRawString == "" || isRawString == "false" {
isRaw = false
if strings.ToLower(isRawString) == "true" {
isRaw = true
}

err := s.pinAPI.PinFiles(fileAddr, isRaw, "")
Expand Down
13 changes: 13 additions & 0 deletions api/http/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ func TestPinUnpinAPI(t *testing.T) {
if string(unpinMessage) != expectedunPinMsg {
t.Fatalf("pin message mismatch, expected %x, got %x", expectedunPinMsg, unpinMessage)
}

// get the list of files pinned again
unpinnedInfo := listPinnedFiles(t, srv)
listInfosUnpin := make([]pin.FileInfo, 0)
err = json.Unmarshal(unpinnedInfo, &listInfosUnpin)
if err != nil {
t.Fatal(err)
}

// Check if the pinned file is not present in the list pin command
if len(listInfosUnpin) != 0 {
t.Fatalf("roothash is in list of pinned files")
}
}

// Test the transparent resolving of feed updates with bzz:// scheme
Expand Down

0 comments on commit 055ed27

Please sign in to comment.