Support provider in database
Change-Id: I0c4a727cb29d2e9319e6aafefccd1beff41bd7be
diff --git a/service.go b/service.go
index 130b1f4..e53c046 100644
--- a/service.go
+++ b/service.go
@@ -46,9 +46,9 @@
c.String(http.StatusExpectationFailed, err.Error())
}
-func add(corpusID, docID, textID string, url string) error {
+func add(corpusID, docID, textID string, provider string, url string) error {
err := db.Update(func(txn *badger.Txn) error {
- err := txn.Set([]byte(corpusID+"/"+docID+"/"+textID), []byte(url))
+ err := txn.Set([]byte(corpusID+"/"+docID+"/"+textID), []byte(provider+","+url))
return err
})
return err
@@ -74,9 +74,9 @@
r.LoadHTMLGlob("templates/*")
//
- r.GET("/index", func(c *gin.Context) {
+ r.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "main.html", gin.H{
- "korapServer": "https://korap.ids-mannheim.de/",
+ "korapServer": "https://korap.ids-mannheim.de/instance/test",
})
})
diff --git a/service_test.go b/service_test.go
index 643ebe3..936ec7e 100644
--- a/service_test.go
+++ b/service_test.go
@@ -24,14 +24,14 @@
assert.Equal(t, http.StatusNotFound, w.Code)
assert.Equal(t, "No entry found", w.Body.String())
- assert.Nil(t, add("s11", "s12", "s13", "http://example.org"))
+ assert.Nil(t, add("s11", "s12", "s13", "sueddeutsche", "http://example.org"))
w = httptest.NewRecorder()
req, _ = http.NewRequest(http.MethodGet, "/s11/s12/s13", nil)
router.ServeHTTP(w, req)
assert.Equal(t, http.StatusOK, w.Code)
- assert.Equal(t, "http://example.org", w.Body.String())
+ assert.Equal(t, "sueddeutsche,http://example.org", w.Body.String())
}
func TestAssetRoute(t *testing.T) {