Skip to content

Commit

Permalink
Fix falcore benchmark (#2270)
Browse files Browse the repository at this point in the history
fixes #2269
  • Loading branch information
methane authored and knewmanTE committed Sep 14, 2016
1 parent 5747d63 commit d1780c0
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions frameworks/Go/falcore/src/framework_benchmarks/falcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,10 @@ var requiredHeaders = falcore.NewResponseFilter(func(req *falcore.Request, res *
res.Header.Set("Date", time.Now().Format(time.RFC1123))
})

var applicationJson = http.Header{"Content-Type": []string{"application/json"}}
var textPlain = http.Header{"Content-Type": []string{"text/plain"}}
var textHtml = http.Header{"Content-Type": []string{"text/html"}}

// Test 1: JSON serialization
var jsonFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Response {
if req.HttpRequest.URL.Path == "/json" {
resp, _ := responder.JSONResponse(req.HttpRequest, 200, applicationJson, &Message{helloWorldString})
resp, _ := responder.JSONResponse(req.HttpRequest, 200, nil, &Message{helloWorldString})
return resp
}
return nil
Expand All @@ -170,7 +166,7 @@ var dbFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Respons
log.Fatalf("Error scanning world row: %s", err.Error())
}

resp, _ := responder.JSONResponse(req.HttpRequest, 200, applicationJson, &world)
resp, _ := responder.JSONResponse(req.HttpRequest, 200, nil, &world)
return resp
}
return nil
Expand Down Expand Up @@ -204,7 +200,7 @@ var queriesFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Re
log.Fatalf("Error scanning world row: %s", err.Error())
}
}
resp, _ := responder.JSONResponse(req.HttpRequest, 200, applicationJson, &world)
resp, _ := responder.JSONResponse(req.HttpRequest, 200, nil, &world)
return resp
}
return nil
Expand Down Expand Up @@ -236,6 +232,7 @@ var fortuneFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Re
pipeWriter.Close()
}()

textHtml := http.Header{"Content-Type": []string{"text/html"}}
return falcore.SimpleResponse(req.HttpRequest, 200, textHtml, -1, pipeReader)
}
return nil
Expand All @@ -254,7 +251,7 @@ var updateFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Res
worldStatement.QueryRow(rand.Intn(worldRowCount)+1).Scan(&world.Id, &world.RandomNumber)
world.RandomNumber = uint16(rand.Intn(worldRowCount) + 1)
updateStatement.Exec(world.RandomNumber, world.Id)
resp, _ := responder.JSONResponse(req.HttpRequest, 200, applicationJson, &world)
resp, _ := responder.JSONResponse(req.HttpRequest, 200, nil, &world)
return resp
} else {
world := make([]World, n)
Expand All @@ -267,7 +264,7 @@ var updateFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Res
log.Fatalf("Error updating world row: %s", err.Error())
}
}
resp, _ := responder.JSONResponse(req.HttpRequest, 200, applicationJson, world)
resp, _ := responder.JSONResponse(req.HttpRequest, 200, nil, world)
return resp
}

Expand All @@ -278,6 +275,7 @@ var updateFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Res
// Test 6: Plaintext
var plaintextFilter = falcore.NewRequestFilter(func(req *falcore.Request) *http.Response {
if req.HttpRequest.URL.Path == "/plaintext" {
textPlain := http.Header{"Content-Type": []string{"text/plain"}}
return falcore.ByteResponse(req.HttpRequest, 200, textPlain, helloWorldBytes)
}
return nil
Expand Down

0 comments on commit d1780c0

Please sign in to comment.