[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 01/07: serve SPA
From: |
gnunet |
Subject: |
[libeufin] 01/07: serve SPA |
Date: |
Mon, 20 Dec 2021 17:44:44 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
commit d92208611f2cc000e6eb0bc7eb7294ba36e80096
Author: ms <ms@taler.net>
AuthorDate: Sun Dec 19 08:48:13 2021 +0100
serve SPA
---
.../src/main/kotlin/tech/libeufin/sandbox/Main.kt | 23 +++++++++++++++++++++-
sandbox/src/main/resources/static/hello.html | 10 ----------
sandbox/src/main/resources/templates/hello.html | 1 -
3 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 08945b33..34ffeaa1 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -73,6 +73,7 @@ import org.slf4j.LoggerFactory
import org.w3c.dom.Document
import startServer
import tech.libeufin.util.*
+import java.io.IOException
import java.math.BigDecimal
import java.net.BindException
import java.net.URL
@@ -937,7 +938,7 @@ val sandboxApp: Application.() -> Unit = {
// debt limit and possibly other configuration
// (could also be a CLI command for now)
post("/demobanks") {
- throw NotImplementedError("Only available in the CLI.")
+ throw NotImplementedError("Only available in the Sandbox CLI.")
}
get("/demobanks") {
@@ -953,6 +954,26 @@ val sandboxApp: Application.() -> Unit = {
}
get("/demobanks/{demobankid}") {
+ /**
+ * Respond the SPA if the content type is not "application/json".
+ */
+ if (call.request.headers["Content-Type"] != "application/json") {
+ val spa =
ClassLoader.getSystemClassLoader().getResourceAsStream("static/spa.html")
+ if (spa == null) throw internalServerError("SPA not found!")
+ call.respondBytesWriter(contentType = ContentType.Text.Html) {
+ writeWhile {
+ val content = try {
+ spa.read()
+ } catch (e: IOException) {
+ throw internalServerError("Could not load the SPA")
+ }
+ if (content == -1) return@writeWhile false
+ it.put(content.toByte())
+ true
+ }
+ }
+ return@get
+ }
expectAdmin(call.request.basicAuth())
val demobankId = call.getUriComponent("demobankid")
val ret: DemobankConfigEntity = transaction {
diff --git a/sandbox/src/main/resources/static/hello.html
b/sandbox/src/main/resources/static/hello.html
deleted file mode 100644
index 9dc42994..00000000
--- a/sandbox/src/main/resources/static/hello.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <title>Hello</title>
-</head>
-<body>
-Testing the static folder.
-</body>
-</html>
\ No newline at end of file
diff --git a/sandbox/src/main/resources/templates/hello.html
b/sandbox/src/main/resources/templates/hello.html
deleted file mode 100644
index 70e073e2..00000000
--- a/sandbox/src/main/resources/templates/hello.html
+++ /dev/null
@@ -1 +0,0 @@
-Hello, I'm a Jinja '{{ token }}' page!
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libeufin] branch master updated (4482f8d4 -> 1d50e1fc), gnunet, 2021/12/20
- [libeufin] 01/07: serve SPA,
gnunet <=
- [libeufin] 02/07: t_ms -> t_s, gnunet, 2021/12/20
- [libeufin] 03/07: Withdrawal., gnunet, 2021/12/20
- [libeufin] 07/07: SPA, gnunet, 2021/12/20
- [libeufin] 05/07: Withdrawal., gnunet, 2021/12/20
- [libeufin] 06/07: SPA, gnunet, 2021/12/20
- [libeufin] 04/07: move default exchange selection at /confirm, gnunet, 2021/12/20