summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/ApiUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/ApiUtil.java')
-rw-r--r--dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/ApiUtil.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/ApiUtil.java b/dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/ApiUtil.java
new file mode 100644
index 00000000..c72e5fe8
--- /dev/null
+++ b/dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/ApiUtil.java
@@ -0,0 +1,19 @@
+package org.openslx.bwlp.sat.api.handler;
+
+import org.springframework.web.context.request.NativeWebRequest;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class ApiUtil {
+ public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
+ try {
+ HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
+ res.setCharacterEncoding("UTF-8");
+ res.addHeader("Content-Type", contentType);
+ res.getWriter().print(example);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}