Java Code Examples for io.micronaut.http.HttpResponse#ok()
The following examples show how to use
io.micronaut.http.HttpResponse#ok() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SkillController.java From micronaut-aws with Apache License 2.0 | 8 votes |
/** * Handles a POST request. Based on the request parameters, invokes the right method on the {@code Skill}. * * @param httpHeaders HTTP Headers * @param body HTTP Request Body byte array * @return response object that contains the response the servlet sends to the client */ @Post public HttpResponse doPost(HttpHeaders httpHeaders, @Body String body) { try { byte[] serializedRequestEnvelope = body.getBytes(AskHttpServerConstants.CHARACTER_ENCODING); final RequestEnvelope requestEnvelope = objectMapper.readValue(serializedRequestEnvelope, RequestEnvelope.class); requestEnvelopeVerificationService.verify(httpHeaders, serializedRequestEnvelope, requestEnvelope); ResponseEnvelope responseEnvelope = requestEnvelopeService.process(requestEnvelope); if (responseEnvelope != null) { return HttpResponse.ok(responseEnvelope); } } catch (IOException e) { if (LOG.isErrorEnabled()) { LOG.error("Unable to parse a byte array to RequestEnvelope"); } } return HttpResponse.badRequest(); }
Example 2
Source File: HelloWorldMicronautTest.java From micronaut-aws with Apache License 2.0 | 5 votes |
@Get("/multi-cookie") HttpResponse<String> multiCookie() { final MutableHttpResponse<String> response = HttpResponse.ok(BODY_TEXT_RESPONSE); response.cookie(Cookie.of(COOKIE_NAME, COOKIE_VALUE).domain(COOKIE_DOMAIN).path(COOKIE_PATH)) .cookie(Cookie.of(COOKIE_NAME + "2", COOKIE_VALUE + "2").domain(COOKIE_DOMAIN).path(COOKIE_PATH)); return response; }
Example 3
Source File: HelloWorldMicronautTest.java From micronaut-aws with Apache License 2.0 | 4 votes |
@Get("/cookie") HttpResponse<String> cookie() { final MutableHttpResponse<String> response = HttpResponse.ok(BODY_TEXT_RESPONSE); response.cookie(Cookie.of(COOKIE_NAME, COOKIE_VALUE).domain(COOKIE_DOMAIN).path(COOKIE_PATH)); return response; }