mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
26 lines
585 B
Go
26 lines
585 B
Go
package corehttp
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
|
|
commands "github.com/jbenet/go-ipfs/commands"
|
|
cmdsHttp "github.com/jbenet/go-ipfs/commands/http"
|
|
core "github.com/jbenet/go-ipfs/core"
|
|
corecommands "github.com/jbenet/go-ipfs/core/commands"
|
|
)
|
|
|
|
const (
|
|
// TODO rename
|
|
originEnvKey = "API_ORIGIN"
|
|
)
|
|
|
|
func CommandsOption(cctx commands.Context) ServeOption {
|
|
return func(n *core.IpfsNode, mux *http.ServeMux) error {
|
|
origin := os.Getenv(originEnvKey)
|
|
cmdHandler := cmdsHttp.NewHandler(cctx, corecommands.Root, origin)
|
|
mux.Handle(cmdsHttp.ApiPath+"/", cmdHandler)
|
|
return nil
|
|
}
|
|
}
|