Browse Source

the new /json handler shall set content-type to application/json

Gelin Luo 8 years ago
parent
commit
265effee92

+ 4 - 1
frameworks/Java/act/src/main/java/com/techempower/act/AppEntry.java

@@ -6,6 +6,7 @@ import act.Version;
 import act.boot.app.RunApp;
 import act.job.OnAppStart;
 import com.alibaba.fastjson.JSON;
+import org.osgl.http.H;
 
 public class AppEntry {
 
@@ -28,7 +29,9 @@ public class AppEntry {
 
 	@OnAppStart
 	public void routing() {
-		Act.get("/json", context -> context.resp().writeContent(JSON.toJSONString(new Message(HELLO_WORLD))));
+		Act.get("/json", context -> context.resp()
+				.contentType(H.Format.JSON.contentType())
+				.writeContent(JSON.toJSONString(new Message(HELLO_WORLD))));
 	}
 
 	public static void main(String[] args) throws Exception {

+ 4 - 0
frameworks/Java/act/src/main/resources/conf/common/app.properties

@@ -1,5 +1,9 @@
+# follow Java world convention
+http.port=8080
+
 # disable CLI service
 cli=false
+
 # disable internal metric service
 metric=false
 

+ 0 - 2
frameworks/Java/act/src/main/resources/conf/prod/app.properties

@@ -1,2 +0,0 @@
-http.port=8080
-cli.port=8081