mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-27 05:17:49 +08:00
commands/http: Made Handler set request contexts
This commit is contained in:
parent
289bce6bdb
commit
29b96b64a5
@ -9,9 +9,9 @@ import (
|
||||
"github.com/jbenet/go-ipfs/core/commands"
|
||||
)
|
||||
|
||||
type Handler struct{}
|
||||
|
||||
// TODO: store ipfsnode context
|
||||
type Handler struct {
|
||||
Ctx cmds.Context
|
||||
}
|
||||
|
||||
func (i Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
path := strings.Split(r.URL.Path, "/")[3:]
|
||||
@ -27,8 +27,11 @@ func (i Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// build the Request and call the command
|
||||
// build the Request
|
||||
req := cmds.NewRequest(path, opts, nil, nil)
|
||||
req.SetContext(i.Ctx)
|
||||
|
||||
// call the command
|
||||
res := commands.Root.Call(req)
|
||||
|
||||
// set the Content-Type based on res output
|
||||
|
||||
Loading…
Reference in New Issue
Block a user