Send plugin.json as a separate describing path
Change-Id: I1b2663f1cc1218ea6147f4f92d665fd52da11168
diff --git a/assets/manifest.json b/assets/plugin.json
similarity index 100%
rename from assets/manifest.json
rename to assets/plugin.json
diff --git a/service.go b/service.go
index 0c88a69..0560786 100644
--- a/service.go
+++ b/service.go
@@ -88,16 +88,19 @@
}(),
)
- //
+ // Return widget page
r.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "main.html", gin.H{
"korapServer": korapServer,
})
})
+ // Return provider information
r.HEAD("/:corpus_id/:doc_id/:text_id", CheckSaleUrl)
r.GET("/:corpus_id/:doc_id/:text_id", CheckSaleUrl)
- r.Static("/assets", "./assets")
+
+ // Return plugin manifest
+ r.StaticFile("/plugin.json", "./assets/plugin.json")
return r
}
diff --git a/service_test.go b/service_test.go
index 5efcd59..08a576b 100644
--- a/service_test.go
+++ b/service_test.go
@@ -45,7 +45,7 @@
assert.Equal(t, "No entry found", w.Body.String())
}
-func TestAssetRoute(t *testing.T) {
+func TestWidgetRoute(t *testing.T) {
router := setupRouter()
@@ -74,3 +74,17 @@
assert.Contains(t, w.Body.String(), "data-server=\"https://korap.ids-mannheim.de/instance/test\"")
assert.Contains(t, w.Body.String(), "<title>External Provider</title>")
}
+
+func TestAssetRoute(t *testing.T) {
+
+ router := setupRouter()
+
+ w := httptest.NewRecorder()
+ req, _ := http.NewRequest(http.MethodGet, "/plugin.json", nil)
+
+ router.ServeHTTP(w, req)
+
+ assert.Equal(t, http.StatusOK, w.Code)
+ assert.Equal(t, w.Header().Get("Content-Type"), "application/json")
+ assert.Contains(t, w.Body.String(), "permissions")
+}