-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: map blobstore implements filesystemer #14
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some suggestions to look into (non-blocking)
@@ -36,19 +36,7 @@ func NewBlobGetHandler(blobs blobstore.Blobstore) func(http.ResponseWriter, *htt | |||
if fsblobs, ok := blobs.(blobstore.FileSystemer); ok { | |||
serveHTTP := http.FileServer(fsblobs.FileSystem()).ServeHTTP | |||
return func(w http.ResponseWriter, r *http.Request) { | |||
_, bytes, err := multibase.Decode(r.PathValue("blob")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be simpler with ServeFile instead of FileServer.
also go errata: if you just want to use system utils, you may find ServeFileFS and FileServerFS easer cause you can just use some system utils (if this is actually helpful)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes - looks more appropriate. I didn't realize it existed! If I have a moment I'll look into replacing it.
@@ -28,7 +28,12 @@ func (srv *Server) Serve(mux *http.ServeMux) { | |||
|
|||
func NewHandler(server server.ServerView) func(http.ResponseWriter, *http.Request) { | |||
return func(w http.ResponseWriter, r *http.Request) { | |||
res, _ := server.Request(ucanhttp.NewHTTPRequest(r.Body, r.Header)) | |||
res, err := server.Request(ucanhttp.NewHTTPRequest(r.Body, r.Header)) | |||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@@ -194,3 +191,21 @@ func NewFsBlobstore(rootdir string, tmpdir string) (*FsBlobstore, error) { | |||
} | |||
return &FsBlobstore{rootdir, tmpdir}, nil | |||
} | |||
|
|||
type fsDir struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again you may want to look at fs.FS
This PR enables the map blobstore to present itself as a
http.FileSystem
. This is useful for testing with an ephemeral storage node.