[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taldir] branch master updated: refactor tos into taler-go
From: |
gnunet |
Subject: |
[taler-taldir] branch master updated: refactor tos into taler-go |
Date: |
Tue, 19 Jul 2022 15:56:25 +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 4a63cc4 refactor tos into taler-go
4a63cc4 is described below
commit 4a63cc4b6c6846f6c1e3188124a691d564a80664
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue Jul 19 15:56:21 2022 +0200
refactor tos into taler-go
---
go.mod | 5 ++--
pkg/rest/taldir.go | 85 ++----------------------------------------------------
2 files changed, 5 insertions(+), 85 deletions(-)
diff --git a/go.mod b/go.mod
index e04561b..8f184cb 100644
--- a/go.mod
+++ b/go.mod
@@ -12,9 +12,8 @@ require (
github.com/mattn/go-sqlite3 v1.14.14 // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
- golang.org/x/text v0.3.7
- gopkg.in/ini.v1 v1.66.4
+ gopkg.in/ini.v1 v1.66.6
gorm.io/driver/postgres v1.3.4
gorm.io/gorm v1.23.4
- taler.net/taler-go.git v0.0.0-20220719120550-b4025837dad5
+ taler.net/taler-go.git v0.0.0-20220719135513-36eb87bf37a3
)
diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go
index c14cdcb..10d0477 100644
--- a/pkg/rest/taldir.go
+++ b/pkg/rest/taldir.go
@@ -29,9 +29,7 @@ import (
"encoding/json"
"fmt"
"html/template"
- "io/ioutil"
"log"
- "mime"
"net/http"
"os"
"os/exec"
@@ -41,7 +39,6 @@ import (
gnunetutil "git.gnunet.org/gnunet-go.git/pkg/util"
"github.com/gorilla/mux"
"github.com/skip2/go-qrcode"
- "golang.org/x/text/language"
"gopkg.in/ini.v1"
"gorm.io/driver/postgres"
"gorm.io/gorm"
@@ -49,6 +46,7 @@ import (
"taler.net/taldir/internal/gana"
"taler.net/taldir/internal/util"
"taler.net/taler-go.git/pkg/merchant"
+ tos "taler.net/taler-go.git/pkg/rest"
)
// Taldir is the primary object of the Taldir service
@@ -594,88 +592,11 @@ func (t *Taldir) ClearDatabase() {
}
func (t *Taldir) termsResponse(w http.ResponseWriter, r *http.Request) {
- fileType :=
t.Cfg.Section("taldir").Key("default_doc_filetype").MustString("text/html")
- termsLocation :=
t.Cfg.Section("taldir").Key("default_tos_path").MustString("terms/")
- for _, typ := range r.Header["Accept"] {
- for _, a := range
strings.Split(t.Cfg.Section("taldir").Key("supported_doc_filetypes").String(),
" ") {
- if typ == a {
- fileType = a
- }
- }
- }
-
- if len(r.Header.Get("Accept-Language")) != 0 {
- acceptLangs, _, _ :=
language.ParseAcceptLanguage(r.Header.Get("Accept-Language"))
- for _, lang := range acceptLangs {
- extensions, _ := mime.ExtensionsByType(fileType)
- for _, ext := range extensions {
- docFile := fmt.Sprintf("%s/%s/0%s",
termsLocation, lang.String(), ext)
- log.Printf("Trying %s\n", docFile)
- fileBytes, err := ioutil.ReadFile(docFile)
- if nil == err {
- w.Header().Set("Content-Type", fileType)
- w.Write(fileBytes)
- return
- }
- }
- }
- }
- // Default document in expected/default format
- defaultLanguage :=
t.Cfg.Section("taldir").Key("default_doc_lang").MustString("en")
- extensions, _ := mime.ExtensionsByType(fileType)
- for _, ext := range extensions {
- docFile := fmt.Sprintf("%s/%s/0%s", termsLocation,
defaultLanguage, ext)
- log.Println("Trying " + docFile)
- fileBytes, err := ioutil.ReadFile(docFile)
- if nil == err {
- w.Header().Set("Content-Type", fileType)
- w.Write(fileBytes)
- return
- }
- }
- w.WriteHeader(http.StatusNotFound)
+ tos.ServiceTermsResponse(t.Cfg.Section("taldir"), w, r)
}
func (t *Taldir) privacyResponse(w http.ResponseWriter, r *http.Request) {
- fileType :=
t.Cfg.Section("taldir").Key("default_doc_filetype").MustString("text/html")
- termsLocation :=
t.Cfg.Section("taldir").Key("default_pp_path").MustString("privacy/")
- for _, typ := range r.Header["Accept"] {
- for _, a := range
strings.Split(t.Cfg.Section("taldir").Key("supported_doc_filetypes").String(),
" ") {
- if typ == a {
- fileType = a
- }
- }
- }
-
- if len(r.Header.Get("Accept-Language")) != 0 {
- acceptLangs, _, _ :=
language.ParseAcceptLanguage(r.Header.Get("Accept-Language"))
- for _, lang := range acceptLangs {
- extensions, _ := mime.ExtensionsByType(fileType)
- for _, ext := range extensions {
- docFile := fmt.Sprintf("%s/%s/0%s",
termsLocation, lang.String(), ext)
- log.Printf("Trying %s\n", docFile)
- fileBytes, err := ioutil.ReadFile(docFile)
- if nil == err {
- w.Header().Set("Content-Type", fileType)
- w.Write(fileBytes)
- return
- }
- }
- }
- }
- // Default document in expected/default format
- defaultLanguage :=
t.Cfg.Section("taldir").Key("default_doc_lang").MustString("en")
- extensions, _ := mime.ExtensionsByType(fileType)
- for _, ext := range extensions {
- docFile := fmt.Sprintf("%s/%s/0%s", termsLocation,
defaultLanguage, ext)
- fileBytes, err := ioutil.ReadFile(docFile)
- if nil == err {
- w.Header().Set("Content-Type", fileType)
- w.Write(fileBytes)
- return
- }
- }
- w.WriteHeader(http.StatusNotFound)
+ tos.PrivacyPolicyResponse(t.Cfg.Section("taldir"), w, r)
}
func (t *Taldir) setupHandlers() {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-taldir] branch master updated: refactor tos into taler-go,
gnunet <=