public static void returnError(RakamHttpRequest request, String msg, HttpResponseStatus status) { ByteBuf byteBuf = Unpooled.wrappedBuffer(JsonHelper.encodeAsBytes(errorMessage(msg, status))); DefaultFullHttpResponse errResponse = new DefaultFullHttpResponse(HTTP_1_1, status, byteBuf); setBrowser(request, errResponse); request.response(errResponse).end(); }
wr.write(JsonHelper.encodeAsBytes(ImmutableMap.of("lua_source", txtContent, "timeout", 60)));
@Path("/data") @GET @IgnoreApi public void data(RakamHttpRequest request) { Map<String, List<String>> params = request.params(); List<String> api_key = params.get("read_key"); if (api_key == null || api_key.isEmpty()) { request.response("\"read_key is missing\"", BAD_REQUEST).end(); return; } // since this endpoint is created for clients to read the ab-testing rule, // the permission is WRITE_KEY String project = apiKeyService.getProjectOfApiKey(api_key.get(0), ApiKeyService.AccessKeyType.WRITE_KEY); request.response(JsonHelper.encodeAsBytes(metadata.getReports(project))) .end(); }
LOGGER.error(new RuntimeException(sample.toString(), e), "Error executing EventStore " + (single ? "store" : "batch") + " method."); return completedFuture(new HeaderDefaultFullHttpResponse(HTTP_1_1, INTERNAL_SERVER_ERROR, Unpooled.wrappedBuffer(encodeAsBytes(errorMessage("An error occurred", INTERNAL_SERVER_ERROR))), responseHeaders)); } else { return new HeaderDefaultFullHttpResponse(HTTP_1_1, CONFLICT, Unpooled.wrappedBuffer(encodeAsBytes(result)), responseHeaders);
sessionParameters.put("external.source_options", getEncoder().encodeToString(encodeAsBytes(params)));
"Error while storing event."); return new HeaderDefaultFullHttpResponse(HTTP_1_1, INTERNAL_SERVER_ERROR, Unpooled.wrappedBuffer(encodeAsBytes(errorMessage("An error occurred", INTERNAL_SERVER_ERROR))), responseHeaders);
Unpooled.wrappedBuffer(encodeAsBytes(errorMessage("An error occurred: " + e.getMessage(), INTERNAL_SERVER_ERROR))), responseHeaders); Unpooled.wrappedBuffer(encodeAsBytes(SuccessMessage.success())), responseHeaders); }, mapEvents);
@Override public void operationComplete(Future<Object> future) throws Exception { if (future.await(1, TimeUnit.SECONDS)) { Object body = future.getNow(); if (body == null) { return; } if (!(body instanceof ScriptObjectMirror)) { returnError(request, "The script must return an object or array {collection: '', properties: {}}", BAD_REQUEST); } ScriptObjectMirror json = (ScriptObjectMirror) ((ScriptObjectMirror) body).eval("JSON"); Object stringify = json.callMember("stringify", body); request.response(stringify.toString()).end(); } else { byte[] bytes = JsonHelper.encodeAsBytes(errorMessage("Webhook code timeouts.", INTERNAL_SERVER_ERROR)); request.response(bytes, INTERNAL_SERVER_ERROR).end(); } } });
byte[] bytes = JsonHelper.encodeAsBytes(errorMessage("Webhook code timeouts.", INTERNAL_SERVER_ERROR));
bytes = JsonHelper.encodeAsBytes(result.getResult()); break; default: