summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/ApiUtil.java
diff options
context:
space:
mode:
authorManuel Bentele2021-12-23 15:13:52 +0100
committerManuel Bentele2021-12-23 15:13:52 +0100
commit14e7f8024066253b312b942b8f2f3491b5ef19d8 (patch)
treeb82e9017832621e24b9ee4952d1e27242a592574 /dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/ApiUtil.java
parent[SERVER] Add Maven profile to generate server API automatically (diff)
downloadtutor-module-feature/dsmd-openapi.tar.gz
tutor-module-feature/dsmd-openapi.tar.xz
tutor-module-feature/dsmd-openapi.zip
[SERVER] Add source code of autogenerated server APIfeature/dsmd-openapi
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);
+ }
+ }
+}