Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
api: expose headers via HttpApi, copy headers during request build
Browse files Browse the repository at this point in the history
  • Loading branch information
postables committed May 1, 2019
1 parent d04afa0 commit 033befd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"net/http"
gohttp "net/http"
"os"
"path"
Expand Down Expand Up @@ -32,9 +33,9 @@ var ErrApiNotFound = errors.New("ipfs api address could not be found")
// For interface docs see
// https://godoc.org/github.com/ipfs/interface-go-ipfs-core#CoreAPI
type HttpApi struct {
url string
httpcli gohttp.Client

url string
httpcli gohttp.Client
Headers http.Header
applyGlobal func(*RequestBuilder)
}

Expand Down Expand Up @@ -175,10 +176,17 @@ func (api *HttpApi) WithOptions(opts ...caopts.ApiOption) (iface.CoreAPI, error)
}

func (api *HttpApi) Request(command string, args ...string) *RequestBuilder {
var headers map[string]string
if api.Headers != nil {
for k := range api.Headers {
headers[k] = api.Headers.Get(k)
}
}
return &RequestBuilder{
command: command,
args: args,
shell: api,
headers: headers,
}
}

Expand Down

0 comments on commit 033befd

Please sign in to comment.