From 29b96b64a58c4e1638e835954fb451dc39b9111f Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 27 Oct 2014 18:14:24 -0700 Subject: [PATCH] commands/http: Made Handler set request contexts --- commands/http/handler.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/commands/http/handler.go b/commands/http/handler.go index 42497a0a2..682ed0078 100644 --- a/commands/http/handler.go +++ b/commands/http/handler.go @@ -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