mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 18:20:27 +00:00
Authorization: Scope-Probe token=<token>
This commit is contained in:
@@ -52,7 +52,7 @@ func (p HTTPPublisher) Publish(rpt report.Report) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Set("Authorization", p.token)
|
||||
req.Header.Set("Authorization", AuthorizationHeader(p.token))
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -64,6 +64,12 @@ func (p HTTPPublisher) Publish(rpt report.Report) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AuthorizationHeader returns a value suitable for an HTTP Authorization
|
||||
// header, based on the passed token string.
|
||||
func AuthorizationHeader(token string) string {
|
||||
return fmt.Sprintf("Scope-Probe token=%s", token)
|
||||
}
|
||||
|
||||
// MultiPublisher implements Publisher over a set of publishers.
|
||||
type MultiPublisher struct {
|
||||
mtx sync.RWMutex
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestHTTPPublisher(t *testing.T) {
|
||||
)
|
||||
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if want, have := token, r.Header.Get("Authorization"); want != have {
|
||||
if want, have := xfer.AuthorizationHeader(token), r.Header.Get("Authorization"); want != have {
|
||||
t.Errorf("want %q, have %q", want, have)
|
||||
}
|
||||
var have report.Report
|
||||
|
||||
Reference in New Issue
Block a user