mirror of https://github.com/usbharu/Hideout.git
24 lines
620 B
Plaintext
24 lines
620 B
Plaintext
|
package {{apiPackage}}
|
||
|
|
||
|
{{^reactive}}
|
||
|
import org.springframework.web.context.request.NativeWebRequest
|
||
|
|
||
|
import {{javaxPackage}}.servlet.http.HttpServletResponse
|
||
|
import java.io.IOException
|
||
|
{{/reactive}}
|
||
|
|
||
|
object ApiUtil {
|
||
|
{{^reactive}}
|
||
|
fun setExampleResponse(req: NativeWebRequest, contentType: String, example: String) {
|
||
|
try {
|
||
|
val res = req.getNativeResponse(HttpServletResponse::class.java)
|
||
|
res?.characterEncoding = "UTF-8"
|
||
|
res?.addHeader("Content-Type", contentType)
|
||
|
res?.writer?.print(example)
|
||
|
} catch (e: IOException) {
|
||
|
throw RuntimeException(e)
|
||
|
}
|
||
|
}
|
||
|
{{/reactive}}
|
||
|
}
|