feat: initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user