json method
Implementation
HttpResponse json([dynamic data]) {
final config = App().container.make<AppConfig>();
final cookie = Cookie(
'xsrf-api-token-${config.get('app.timestamp').toString().replaceAll(':', '-')}',
"${config.get('app.id')}",
)
..httpOnly = true
..secure = true
..sameSite = SameSite.lax;
response.headers.contentType = ContentType.json;
return response
..cookies.add(cookie)
..write(jsonEncode(data))
..close();
}