-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
186 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
package: github.com/RackHD/neighborhood-manager | ||
import: | ||
- package: github.com/hashicorp/consul | ||
version: ~0.7.0 | ||
subpackages: | ||
- api | ||
- package: github.com/hashicorp/go-cleanhttp | ||
- package: github.com/king-jam/gossdp | ||
- package: github.com/spf13/viper | ||
testImport: | ||
- package: github.com/onsi/ginkgo | ||
version: ~1.2.0 | ||
- package: github.com/onsi/gomega | ||
version: ~1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package proxy | ||
|
||
import ( | ||
"io/ioutil" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
// Response is the internal proxy response object | ||
type Response struct { | ||
Header http.Header | ||
StatusCode int | ||
Body []byte | ||
RequestURL string | ||
Error error | ||
} | ||
|
||
// NewResponse copies a http.Response into a proxy Response | ||
func NewResponse(resp *http.Response) (*Response, error) { | ||
body, err := ioutil.ReadAll(resp.Body) | ||
if err != nil { | ||
log.Printf("Error reading Response.Body %s\n", err) | ||
return nil, err | ||
} | ||
proxyResponse := &Response{ | ||
Header: resp.Header, | ||
StatusCode: resp.StatusCode, | ||
Body: body, | ||
RequestURL: resp.Request.URL.String(), | ||
Error: nil, | ||
} | ||
return proxyResponse, err | ||
} | ||
|
||
// NewResponseFromError sets errors | ||
func NewResponseFromError(err error) *Response { | ||
proxyRespnse := &Response{ | ||
StatusCode: 500, | ||
Error: err, | ||
} | ||
return proxyRespnse | ||
} | ||
|
||
// NewRequest copies a http.Request & Header and sets the new host | ||
func NewRequest(r *http.Request, host string) (*http.Request, error) { | ||
req, err := http.NewRequest(r.Method, "http://"+host+r.URL.Path, r.Body) | ||
if err != nil { | ||
return nil, err | ||
} | ||
for k, v := range r.Header { | ||
for _, value := range v { | ||
req.Header.Set(k, value) | ||
} | ||
} | ||
return req, nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters