Skip to content

Commit

Permalink
gateway: cleanup err switch
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>


This commit was moved from ipfs/kubo@818e0e4
  • Loading branch information
magik6k committed Jan 5, 2019
1 parent 4b82d6d commit 27d98a2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions gateway/core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
}

idx, err := i.api.Unixfs().Get(ctx, coreiface.Join(resolvedPath, "index.html"))
switch {
case err == nil:
switch err.(type) {
case nil:
dirwithoutslash := urlPath[len(urlPath)-1] != '/'
goget := r.URL.Query().Get("go-get") == "1"
if dirwithoutslash && !goget {
Expand All @@ -279,10 +279,9 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
// write to request
http.ServeContent(w, r, "index.html", modtime, f)
return
case resolver.ErrNoLink:
// no index.html; noop
default:
if _, ok := err.(resolver.ErrNoLink); ok {
break
}
internalWebError(w, err)
return
}
Expand Down

0 comments on commit 27d98a2

Please sign in to comment.