diff --git a/executor/executor.go b/executor/executor.go index 602b56a..7c84d58 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "log" + "net/http" "os" "time" @@ -63,6 +64,7 @@ func Run(c Config) (*Result, error) { p.Stdout = c.Stdout p.Stderr = c.Stderr p.Logger = log.New(io.MultiWriter(c.LogSink, os.Stdout), c.Name+" ", log.LstdFlags) + p.HC.Transport = WasmcloudBrandingTransport(c.Name, p.HC.Transport) gp := &compiler.SimpleGasPolicy{GasPerInstruction: 1} vm, err := exec.NewVirtualMachine(c.Binary, c.VMConfig, p, gp) @@ -95,3 +97,20 @@ func Run(c Config) (*Result, error) { StartTime: begin, }, nil } + +func WasmcloudBrandingTransport(handlerName string, rt http.RoundTripper) http.RoundTripper { + return wasmcloudBrandingTransport{ + rt: rt, + handlerName: handlerName, + } +} + +type wasmcloudBrandingTransport struct { + rt http.RoundTripper + handlerName string +} + +func (w wasmcloudBrandingTransport) RoundTrip(r *http.Request) (*http.Response, error) { + r.Header.Set("User-Agent", r.Header.Get("User-Agent")+" wasmcloud/"+w.handlerName) + return w.rt.RoundTrip(r) +} diff --git a/go.mod b/go.mod index 036958c..3affaac 100644 --- a/go.mod +++ b/go.mod @@ -21,6 +21,6 @@ require ( github.com/rogpeppe/go-internal v1.5.0 golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392 within.website/ln v0.7.0 - within.website/olin v0.3.0 + within.website/olin v0.3.1 within.website/x v1.2.1 ) diff --git a/go.sum b/go.sum index 77bff61..27af842 100644 --- a/go.sum +++ b/go.sum @@ -451,5 +451,7 @@ within.website/olin v0.2.0 h1:mfUxRVaqi2hfasOMTyuatCrVkDn6carZegFxFEqcF6w= within.website/olin v0.2.0/go.mod h1:YL69W52El9WiyFH/tM1zf7+tqUGw2vLb1MGrr/WqbKo= within.website/olin v0.3.0 h1:uicBbzY0Tlez2zZxlyjYnq+J/1nGAv5wC2XtldLwfek= within.website/olin v0.3.0/go.mod h1:YL69W52El9WiyFH/tM1zf7+tqUGw2vLb1MGrr/WqbKo= +within.website/olin v0.3.1 h1:697dGAHeAjxTXnYR/jW2NGPAnRonnuQULtfzRfPtAF4= +within.website/olin v0.3.1/go.mod h1:YL69W52El9WiyFH/tM1zf7+tqUGw2vLb1MGrr/WqbKo= within.website/x v1.2.1 h1:prNr9fWf/O7irD2hS/1na7GW/jiWdbuLnWNy1ZMkf+8= within.website/x v1.2.1/go.mod h1:f6yg4hO/pprWxgRNHxKZU0Z/aKCsZq+WLg3iR8n1V6U=