Move to vendor dir
This commit is contained in:
24
vendor/github.com/xoebus/statham/.gitignore
generated
vendored
Normal file
24
vendor/github.com/xoebus/statham/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
21
vendor/github.com/xoebus/statham/LICENSE
generated
vendored
Normal file
21
vendor/github.com/xoebus/statham/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Chris Brown
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
26
vendor/github.com/xoebus/statham/README.md
generated
vendored
Normal file
26
vendor/github.com/xoebus/statham/README.md
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# statham
|
||||
|
||||
*jason statham is the per-domain transporter*
|
||||
|
||||

|
||||
|
||||
## installation
|
||||
|
||||
``` sh
|
||||
go get github.com/xoebus/statham
|
||||
```
|
||||
|
||||
## usage
|
||||
|
||||
``` go
|
||||
defaultTransport := &http.Transport{...}
|
||||
tr1 := &http.Transport{...}
|
||||
tr2 := &http.Transport{...}
|
||||
|
||||
tr := statham.NewTransport(defaultTransport, statham.Mapping{
|
||||
"github.com": tr1,
|
||||
"google.com": tr2,
|
||||
})
|
||||
|
||||
client := &http.Client{Transport: tr}
|
||||
```
|
26
vendor/github.com/xoebus/statham/statham.go
generated
vendored
Normal file
26
vendor/github.com/xoebus/statham/statham.go
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package statham
|
||||
|
||||
import "net/http"
|
||||
|
||||
func NewTransport(defaultTr http.RoundTripper, mapping Mapping) http.RoundTripper {
|
||||
return &roundTripper{
|
||||
defaultTripper: defaultTr,
|
||||
mapping: mapping,
|
||||
}
|
||||
}
|
||||
|
||||
type Mapping map[string]http.RoundTripper
|
||||
|
||||
type roundTripper struct {
|
||||
defaultTripper http.RoundTripper
|
||||
mapping Mapping
|
||||
}
|
||||
|
||||
func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
transport, found := rt.mapping[req.URL.Host]
|
||||
if !found {
|
||||
return rt.defaultTripper.RoundTrip(req)
|
||||
}
|
||||
|
||||
return transport.RoundTrip(req)
|
||||
}
|
Reference in New Issue
Block a user