gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] 01/02: Helper to extract URI parameters.


From: gnunet
Subject: [libeufin] 01/02: Helper to extract URI parameters.
Date: Wed, 08 Apr 2020 16:54:05 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository libeufin.

commit 523a32feb530c0b9392624a794a8984bf9f81c4a
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Apr 7 23:39:18 2020 +0200

    Helper to extract URI parameters.
---
 nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt  | 6 ++++++
 nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt    | 6 ++++--
 sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 5 -----
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
index 372d414..635f35a 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
@@ -1,5 +1,6 @@
 package tech.libeufin.nexus
 
+import io.ktor.application.ApplicationCall
 import io.ktor.http.HttpStatusCode
 
 /**
@@ -36,6 +37,11 @@ fun expectIdTransaction(param: String?): 
EbicsSubscriberEntity {
     return EbicsSubscriberEntity.findById(param) ?: throw 
NexusError(HttpStatusCode.NotFound, "Subscriber: $param not found")
 }
 
+fun ApplicationCall.expectUrlParameter(name: String): String {
+    return this.request.queryParameters[name]
+        ?: throw NexusError(HttpStatusCode.BadRequest, "Parameter '$name' not 
provided in URI")
+}
+
 /* Needs a transaction{} block to be called */
 fun expectAcctidTransaction(param: String?): EbicsAccountInfoEntity {
     if (param == null) {
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index 9c8ef51..4cf24f8 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -101,7 +101,6 @@ class Taler(app: Route) {
     private data class TalerOutgoingHistory(
         var outgoing_transactions: MutableList<TalerOutgoingBankTransaction> = 
mutableListOf()
     )
-
     /**
      * Test APIs' data structures.
      */
@@ -116,7 +115,10 @@ class Taler(app: Route) {
         val row_id: Long
     )
 
-    // throws error if password is wrong
+    /**
+     * throws error if password is wrong
+     * @param authorization the Authorization:-header line.
+     */
     private fun authenticateRequest(authorization: String?) {
         val headerLine = authorization ?: throw NexusError(
             HttpStatusCode.BadRequest, "Authentication:-header line not found"
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index ea85bf5..2af9c6a 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -225,7 +225,6 @@ fun main() {
             }
         }
         routing {
-
             post("/{id}/history") {
                 val req = call.receive<CustomerHistoryRequest>()
                 val customer = findCustomer(call.parameters["id"])
@@ -252,7 +251,6 @@ fun main() {
                 call.respond(ret)
                 return@post
             }
-
             get("/{id}/balance") {
                 val customer = findCustomer(call.parameters["id"])
                 val balance = calculateBalance(customer.id.value, null, null)
@@ -264,7 +262,6 @@ fun main() {
                 )
                 return@get
             }
-
             get("/admin/subscribers") {
                 var ret = AdminGetSubscribers()
                 transaction {
@@ -277,7 +274,6 @@ fun main() {
                 call.respond(ret)
                 return@get
             }
-
             post("/admin/add/subscriber") {
                 val body = call.receive<AdminAddSubscriberRequest>()
 
@@ -332,7 +328,6 @@ fun main() {
                     HttpStatusCode.OK
                 )
                 return@post
-
             }
             get("/ebics/hosts/{id}") {
                 val resp = transaction {

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]