Преглед изворни кода

Merge branch 'master' of https://github.com/robfig/FrameworkBenchmarks into robfig-master

Patrick Falls пре 12 година
родитељ
комит
217642daa9

+ 2 - 1
go/benchmark_config

@@ -8,8 +8,9 @@
       "query_url": "/db?queries=",
       "query_url": "/db?queries=",
       "fortune_url": "/fortune",
       "fortune_url": "/fortune",
       "update_url": "/update?queries=",
       "update_url": "/update?queries=",
+      "plaintext_url": "/plaintext",
       "port": 8080,
       "port": 8080,
       "sort": 27
       "sort": 27
     }
     }
   }]
   }]
-}
+}

+ 8 - 0
go/src/hello/hello.go

@@ -71,6 +71,7 @@ func main() {
 	http.HandleFunc("/json", jsonHandler)
 	http.HandleFunc("/json", jsonHandler)
 	http.HandleFunc("/fortune", fortuneHandler)
 	http.HandleFunc("/fortune", fortuneHandler)
 	http.HandleFunc("/update", updateHandler)
 	http.HandleFunc("/update", updateHandler)
+	http.HandleFunc("/plaintext", plaintextHandler)
 	http.ListenAndServe(":8080", nil)
 	http.ListenAndServe(":8080", nil)
 }
 }
 
 
@@ -79,6 +80,13 @@ func jsonHandler(w http.ResponseWriter, r *http.Request) {
 	json.NewEncoder(w).Encode(&Message{"Hello, world"})
 	json.NewEncoder(w).Encode(&Message{"Hello, world"})
 }
 }
 
 
+var HelloWorld = []byte("Hello, World!")
+
+func plaintextHandler(w http.ResponseWriter, r *http.Request) {
+	w.Header().Set("Content-Type", "text/plain")
+	w.Write(HelloWorld)
+}
+
 func worldHandler(w http.ResponseWriter, r *http.Request) {
 func worldHandler(w http.ResponseWriter, r *http.Request) {
 	n := 1
 	n := 1
 	if nStr := r.URL.Query().Get("queries"); len(nStr) != 0 {
 	if nStr := r.URL.Query().Get("queries"); len(nStr) != 0 {

+ 1 - 0
revel/benchmark_config

@@ -8,6 +8,7 @@
       "query_url": "/db?queries=",
       "query_url": "/db?queries=",
       "fortune_url": "/fortune",
       "fortune_url": "/fortune",
       "update_url": "/update?queries=",
       "update_url": "/update?queries=",
+      "plaintext_url": "/plaintext",
       "port": 8080,
       "port": 8080,
       "sort": 112
       "sort": 112
     }
     }

+ 4 - 0
revel/src/benchmark/app/controllers/app.go

@@ -70,6 +70,10 @@ func (c App) Json() revel.Result {
 	return c.RenderJson(MessageStruct{"Hello, world"})
 	return c.RenderJson(MessageStruct{"Hello, world"})
 }
 }
 
 
+func (c App) Plaintext() revel.Result {
+	return c.RenderText("Hello, World!")
+}
+
 func (c App) Db(queries int) revel.Result {
 func (c App) Db(queries int) revel.Result {
 	if queries <= 1 {
 	if queries <= 1 {
 		var w World
 		var w World

+ 2 - 1
revel/src/benchmark/conf/routes

@@ -2,7 +2,8 @@
 # This file defines all application routes (Higher priority routes first)
 # This file defines all application routes (Higher priority routes first)
 # ~~~~
 # ~~~~
 
 
-GET     /db                                     App.Db
+GET     /plaintext                              App.Plaintext
 GET     /json                                   App.Json
 GET     /json                                   App.Json
+GET     /db                                     App.Db
 GET     /fortune                                App.Fortune
 GET     /fortune                                App.Fortune
 GET     /update                                 App.Update
 GET     /update                                 App.Update