Refactor
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
parent
3713d774ec
commit
6157443144
2 changed files with 3 additions and 3 deletions
|
@ -20,7 +20,7 @@ type SuccessResponse struct {
|
|||
func Handler(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("Running handler...")
|
||||
|
||||
code := utils.GetResponseCode(r)
|
||||
code := utils.GetStatusCode(r)
|
||||
|
||||
w.WriteHeader(code)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
|
|
@ -15,13 +15,13 @@ func GetPort() string {
|
|||
return "8080"
|
||||
}
|
||||
|
||||
func GetResponseCode(r *http.Request) int {
|
||||
func GetStatusCode(r *http.Request) int {
|
||||
// If the `force-fail` header is set, get and return its value.
|
||||
if failCode := r.Header.Get("force-fail"); failCode != "" {
|
||||
log.Println("`force-fail` header set...")
|
||||
|
||||
if code, err := strconv.Atoi(failCode); err == nil {
|
||||
log.Printf("Setting the response code to %d...", code)
|
||||
log.Printf("Setting the status code to %d...", code)
|
||||
|
||||
return code
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue