File tree Expand file tree Collapse file tree 3 files changed +8
-6
lines changed
src/main/java/info/unterrainer/commons/httpserver Expand file tree Collapse file tree 3 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 1717
1818 <modelVersion >4.0.0</modelVersion >
1919 <artifactId >http-server</artifactId >
20- <version >0.2.41 </version >
20+ <version >0.2.42 </version >
2121 <name >HttpServer</name >
2222 <packaging >jar</packaging >
2323
Original file line number Diff line number Diff line change @@ -121,13 +121,10 @@ private void create() {
121121
122122 javalin .before (ctx -> ctx .attribute (Attribute .JAVALIN_SERVER , this ));
123123 javalin .before (ctx -> ctx .attribute (Attribute .RESPONSE_TYPE , ResponseType .JSON ));
124- javalin .before (ctx -> ctx .contentType ( "application/json" ));
124+ javalin .before (ctx -> ctx .attribute ( Attribute . RESPONSE_CONTENT_TYPE , "application/json" ));
125125 javalin .before (this ::unzip );
126126
127- javalin .after (ctx -> render (ctx ));
128- javalin .after (ctx -> {
129- ctx .contentType ("application/json" );
130- });
127+ javalin .after (this ::render );
131128
132129 javalin .error (404 , ctx -> {
133130 ctx .result (jsonMapper .toStringFrom (MessageJson .builder ()
@@ -267,5 +264,9 @@ private void render(final Context ctx) throws IOException {
267264 Integer status = ctx .attribute (Attribute .RESPONSE_STATUS );
268265 if (status != null )
269266 ctx .status (status );
267+
268+ String contentType = ctx .attribute (Attribute .RESPONSE_CONTENT_TYPE );
269+ if (contentType != null )
270+ ctx .contentType (contentType );
270271 }
271272}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ public class Attribute {
88 public static final String RESPONSE_OBJECT = "response_object" ;
99 public static final String RESPONSE_STATUS = "response_status" ;
1010 public static final String RESPONSE_TYPE = "response_type" ;
11+ public static final String RESPONSE_CONTENT_TYPE = "response_content_type" ;
1112
1213 public static final String USER_NAME = "user_name" ;
1314 public static final String USER_GIVEN_NAME = "user_given_name" ;
You can’t perform that action at this time.
0 commit comments