Fix responses
Change-Id: I3d57e16d02c330673d47f728b15a106dd97b174c
diff --git a/service.go b/service.go
index 3230b10..e1ac40d 100644
--- a/service.go
+++ b/service.go
@@ -19,10 +19,9 @@
docID := c.Param("doc_id")
textID := c.Param("text_id")
- /*
- c.Header("Access-Control-Allow-Origin", "null")
- c.Header("Access-Control-Allow-Credentials", "null")
- c.Header("Vary", "Origin")*/
+ c.Header("Access-Control-Allow-Origin", "null")
+ c.Header("Access-Control-Allow-Credentials", "null")
+ c.Header("Vary", "Origin")
err := db.View(func(txn *badger.Txn) error {
@@ -38,7 +37,7 @@
})
if err != nil {
- c.String(http.StatusNotFound, err.Error())
+ return err
}
return nil
@@ -47,8 +46,6 @@
if err != nil {
c.String(http.StatusNotFound, err.Error())
}
-
- c.String(http.StatusExpectationFailed, err.Error())
}
func add(corpusID, docID, textID string, provider string, url string) error {
@@ -80,16 +77,15 @@
//
r.GET("/", func(c *gin.Context) {
- /*
- c.Header("Access-Control-Allow-Origin", "null")
- c.Header("Access-Control-Allow-Credentials", "null")
- c.Header("Vary", "Origin")
- */
+ c.Header("Access-Control-Allow-Origin", "null")
+ c.Header("Access-Control-Allow-Credentials", "null")
+ c.Header("Vary", "Origin")
c.HTML(http.StatusOK, "main.html", gin.H{
"korapServer": "https://korap.ids-mannheim.de/instance/test",
})
})
+ r.HEAD("/:corpus_id/:doc_id/:text_id", CheckSaleUrl)
r.GET("/:corpus_id/:doc_id/:text_id", CheckSaleUrl)
r.Static("/assets", "./assets")
return r