[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] branch master updated: fix JSON content negotiation
From: |
gnunet |
Subject: |
[libeufin] branch master updated: fix JSON content negotiation |
Date: |
Tue, 07 Jun 2022 18:05:15 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
The following commit(s) were added to refs/heads/master by this push:
new 8504d6f1 fix JSON content negotiation
8504d6f1 is described below
commit 8504d6f1c4f4738dcb749fdec28f4abe55f78214
Author: MS <ms@taler.net>
AuthorDate: Tue Jun 7 18:04:45 2022 +0200
fix JSON content negotiation
---
.../src/main/kotlin/tech/libeufin/sandbox/JSON.kt | 6 +++++
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 30 ++++++++++++----------
2 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
index 4636850f..724755af 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/JSON.kt
@@ -140,4 +140,10 @@ data class NewTransactionReq(
val paytoUri: String,
// $currency:X.Y format
val amount: String?
+)
+
+data class SandboxConfig(
+ val currency: String,
+ val version: String,
+ val name: String
)
\ No newline at end of file
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 5b061c1a..6707c678 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -456,6 +456,15 @@ suspend inline fun <reified T : Any>
ApplicationCall.receiveJson(): T {
}
val singleThreadContext = newSingleThreadContext("DB")
+fun setJsonHandler(ctx: ObjectMapper) {
+ ctx.enable(SerializationFeature.INDENT_OUTPUT)
+ ctx.setDefaultPrettyPrinter(DefaultPrettyPrinter().apply {
+ indentArraysWith(DefaultPrettyPrinter.FixedSpaceIndenter.instance)
+ indentObjectsWith(DefaultIndenter(" ", "\n"))
+ })
+ ctx.registerModule(KotlinModule(nullisSameAsDefault = true))
+}
+
val sandboxApp: Application.() -> Unit = {
install(CallLogging) {
this.level = org.slf4j.event.Level.DEBUG
@@ -478,17 +487,11 @@ val sandboxApp: Application.() -> Unit = {
* "xml" and the request made gets somehow assigned the
* "text/plain" type: */
register(ContentType.Text.Plain, XMLEbicsConverter())
+ jackson(contentType = ContentType.Application.Json) {
setJsonHandler(this) }
/**
* Make jackson the default parser. It runs also when
* the Content-Type request header is missing. */
- jackson(contentType = ContentType.Any) {
-
enable(com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT)
- setDefaultPrettyPrinter(DefaultPrettyPrinter().apply {
-
indentArraysWith(DefaultPrettyPrinter.FixedSpaceIndenter.instance)
- indentObjectsWith(DefaultIndenter(" ", "\n"))
- })
- registerModule(KotlinModule(nullisSameAsDefault = true))
- }
+ jackson(contentType = ContentType.Any) { setJsonHandler(this) }
}
install(StatusPages) {
exception<ArithmeticException> { cause ->
@@ -1105,12 +1108,11 @@ val sandboxApp: Application.() -> Unit = {
route("/integration-api") {
get("/config") {
val demobank = ensureDemobank(call)
- call.respond(object {
- val name = "taler-bank-integration"
- // FIXME: avoid hard-coding the version!
- val version = "0:0:0"
- val currency = demobank.currency
- })
+ call.respond(SandboxConfig(
+ name = "taler-bank-integration",
+ version = "0:0:0",
+ currency = demobank.currency
+ ))
return@get
}
post("/withdrawal-operation/{wopid}") {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libeufin] branch master updated: fix JSON content negotiation,
gnunet <=