gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taldir] branch master updated: add version response


From: gnunet
Subject: [taler-taldir] branch master updated: add version response
Date: Mon, 04 Jul 2022 21:40:39 +0200

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

martin-schanzenbach pushed a commit to branch master
in repository taldir.

The following commit(s) were added to refs/heads/master by this push:
     new a7782bc  add version response
a7782bc is described below

commit a7782bc61544982e21e72f69040dcfd59133400b
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Mon Jul 4 21:40:36 2022 +0200

    add version response
---
 go.mod      |  2 +-
 taldir.conf |  4 +++-
 taldir.go   | 67 +++++++++++++++++++++++++++++++++++++++++++++++++------------
 3 files changed, 58 insertions(+), 15 deletions(-)

diff --git a/go.mod b/go.mod
index 24be3e6..00078d6 100644
--- a/go.mod
+++ b/go.mod
@@ -8,7 +8,7 @@ require (
        github.com/jcmturner/gokrb5/v8 v8.2.0 // indirect
        github.com/jinzhu/now v1.1.5 // indirect
        golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
-       gopkg.in/ini.v1 v1.66.4 // indirect
+       gopkg.in/ini.v1 v1.66.4
        gopkg.in/jcmturner/aescts.v1 v1.0.1 // indirect
        gopkg.in/jcmturner/dnsutils.v1 v1.0.1 // indirect
        gopkg.in/jcmturner/goidentity.v3 v3.0.0 // indirect
diff --git a/taldir.conf b/taldir.conf
index b60110c..1d2d95f 100644
--- a/taldir.conf
+++ b/taldir.conf
@@ -4,10 +4,12 @@ validators = "email phone"
 host = "https://taldir.net";
 bind_to = "localhost:11000"
 salt = "ChangeMe"
+supported_methods = email
+monthly_fee = 1 Bazillion Kudos
 
 [taldir-email]
 sender = "taldir@taler.net"
-
+challenge_fee = 0.5 Fantastillion Kudos 
 
 [taldir-pq]
 host = "localhost"
diff --git a/taldir.go b/taldir.go
index 862e8fd..cd502e3 100644
--- a/taldir.go
+++ b/taldir.go
@@ -17,6 +17,32 @@ import (
   "strings"
 )
 
+type VersionResponse struct {
+  // libtool-style representation of the Merchant protocol version, see
+  // 
https://www.gnu.org/software/libtool/manual/html_node/Versioning.html#Versioning
+  // The format is "current:revision:age".
+  Version string `json:"version"`
+
+  // Name of the protocol.
+  Name string `json:"name"` // "taler-directory"
+
+  // Supported registration methods
+  Methods []Method `json:"methods"`
+
+  // fee for one month of registration
+  Monthly_fee string `json:"monthly_fee"`
+
+}
+
+type Method struct {
+  // Name of the method, e.g. "email" or "sms".
+  Name string `json:"name"`
+
+  // per challenge fee
+  Challenge_fee string `json:"challenge_fee"`
+
+}
+
 // A mappind entry from the identity key hash to a wallet key
 // The identity key hash is sha256(sha256(identity)|salt) where identity is
 // one of the identity key types supported (e.g. email)
@@ -192,31 +218,46 @@ func addPendingValidation(w http.ResponseWriter, r 
*http.Request){
   sendEmail(vars["identity"], validation)
 }
 
-// Add a new message
-func addMessageToInbox(w http.ResponseWriter, r *http.Request) {
+func notImplemented(w http.ResponseWriter, r *http.Request) {
+  return
 }
 
-// Add a new message
-func getInboxMessages(w http.ResponseWriter, r *http.Request) {
+func configResponse(w http.ResponseWriter, r *http.Request) {
+  //FIXME properly collect configured methods
+  //cfg.Section("taldir").Key("methods").MustString(""),
+  //=> cfg.Section("taldir-<method>").Key("challenge_fee").MustString("1 
Kudos"),
+  cfg := VersionResponse{
+    Version: "0:0:0",
+    Name: "taler-directory",
+    Monthly_fee: cfg.Section("taldir").Key("monthly_fee").MustString("1 
Kudos"),
+    Methods: []Method{
+      Method{
+        Name: "email",
+        Challenge_fee: 
cfg.Section("taldir-email").Key("challenge_fee").MustString("1 Kudos"),
+      },
+    },
+  }
+  w.Header().Set("Content-Type", "application/json")
+  response, _ := json.Marshal(cfg)
+  w.Write(response)
 }
 
-// Add a new message
-func deleteInboxMessages(w http.ResponseWriter, r *http.Request) {
-}
+func handleRequests() {
+  myRouter := mux.NewRouter().StrictSlash(true)
 
+  /* ToS API */
+  myRouter.HandleFunc("/terms", notImplemented).Methods("GET")
+  myRouter.HandleFunc("/privacy", notImplemented).Methods("GET")
+
+  /* Config API */
+  myRouter.HandleFunc("/config", configResponse).Methods("GET")
 
 
-func handleRequests() {
-  myRouter := mux.NewRouter().StrictSlash(true)
   /* Registration API */
   myRouter.HandleFunc("/directory/{identity_key}", 
returnSingleEntry).Methods("GET")
   myRouter.HandleFunc("/validation/{reference}", 
validateSingleEntry).Methods("GET")
   myRouter.HandleFunc("/register/{identity}", 
addPendingValidation).Methods("POST")
 
-  /* Inbox API */
-  myRouter.HandleFunc("/inbox/{identity_key}", 
addMessageToInbox).Methods("POST")
-  myRouter.HandleFunc("/inbox/{identity_key}", getInboxMessages).Methods("GET")
-  myRouter.HandleFunc("/inbox/{identity_key}/{message_idx}", 
deleteInboxMessages).Methods("DELETE")
   
log.Fatal(http.ListenAndServe(cfg.Section("taldir").Key("bind_to").MustString("localhost:11000"),
 myRouter))
 }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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