summaryrefslogtreecommitdiffstats
path: root/dozentenmodulserver/api/src/main/java/org/openslx/bwlp/sat/api/handler/ApiUtil.java
blob: c72e5fe8d3362e4aa21dd095edcc8071abcb2146 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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);
        }
    }
}