diff options
author | Manuel Bentele | 2021-12-23 15:13:52 +0100 |
---|---|---|
committer | Manuel Bentele | 2021-12-23 15:13:52 +0100 |
commit | 14e7f8024066253b312b942b8f2f3491b5ef19d8 (patch) | |
tree | b82e9017832621e24b9ee4952d1e27242a592574 /dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/ApiUtil.java | |
parent | [SERVER] Add Maven profile to generate server API automatically (diff) | |
download | tutor-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.java | 19 |
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); + } + } +} |