Skip to content

Commit

Permalink
Add readonly api to gateway
Browse files Browse the repository at this point in the history
Based on ipfs/kubo#1389

License: MIT
Signed-off-by: rht <rhtbot@gmail.com>


This commit was moved from ipfs/kubo@dd99a70
  • Loading branch information
rht committed Aug 15, 2015
1 parent feb2df5 commit 671ce95
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gateway/core/corehttp/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) {
}
}

func CommandsOption(cctx commands.Context) ServeOption {
func commandsOption(cctx commands.Context, command *commands.Command) ServeOption {
return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {

cfg := &cmdsHttp.ServerConfig{
Expand All @@ -113,8 +113,16 @@ func CommandsOption(cctx commands.Context) ServeOption {
addCORSDefaults(cfg)
patchCORSVars(cfg, l.Addr())

cmdHandler := cmdsHttp.NewHandler(cctx, corecommands.Root, cfg)
cmdHandler := cmdsHttp.NewHandler(cctx, command, cfg)
mux.Handle(cmdsHttp.ApiPath+"/", cmdHandler)
return mux, nil
}
}

func CommandsOption(cctx commands.Context) ServeOption {
return commandsOption(cctx, corecommands.Root)
}

func CommandsROOption(cctx commands.Context) ServeOption {
return commandsOption(cctx, corecommands.RootRO)
}

0 comments on commit 671ce95

Please sign in to comment.