Skip to content

Commit

Permalink
default case should be first or last in switch statement; replaced de…
Browse files Browse the repository at this point in the history
…precated xerrors call
  • Loading branch information
10d9e committed Jun 8, 2023
1 parent 28fffc2 commit 437ebee
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions api/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
mdagipld "github.com/ipfs/go-ipld-format"
"github.com/ipfs/go-path/resolver"
uio "github.com/ipfs/go-unixfs/io"
"golang.org/x/xerrors"
)

var (
Expand Down Expand Up @@ -360,10 +359,10 @@ func ServeDir(ctx context.Context, n mdagipld.Node, w http.ResponseWriter, req *

http.ServeContent(w, req, "index.html", time.Time{}, dr)
return nil

case errors.Is(err, os.ErrNotExist):
default:
return err
case xerrors.Is(err, os.ErrNotExist):

}

templates, err := template.ParseFiles("templates/dir.html")
Expand All @@ -375,6 +374,9 @@ func ServeDir(ctx context.Context, n mdagipld.Node, w http.ResponseWriter, req *
templates.Lookup("dir.html")

requestURI, err := url.ParseRequestURI(req.RequestURI)
if err != nil {
return err
}

if err := dir.ForEachLink(ctx, func(lnk *mdagipld.Link) error {
href := gopath.Join(requestURI.Path, lnk.Name)
Expand Down

0 comments on commit 437ebee

Please sign in to comment.