Files
schemas/ctl/transport.go
T
2022-10-09 20:37:48 +02:00

23 lines
418 B
Go

package ctl
import (
"net/http"
)
type headerTransport struct {
tripper http.RoundTripper
apiKey string
}
func NewTransport(tripper http.RoundTripper, apiKey string) *headerTransport {
return &headerTransport{
tripper: tripper,
apiKey: apiKey,
}
}
func (t *headerTransport) RoundTrip(req *http.Request) (*http.Response, error) {
req.Header.Set("X-Api-Key", t.apiKey)
return t.tripper.RoundTrip(req)
}