diff --git a/api.go b/api.go index 2b187b7..296e323 100644 --- a/api.go +++ b/api.go @@ -76,7 +76,11 @@ func (s *Arseeding) runAPI(port string) { v1.GET("/bundle/fees", s.bundleFees) v1.GET("/bundle/fee/:size/:currency", s.bundleFee) v1.GET("/bundle/orders/:signer", s.getOrders) - v1.GET("/:id", s.dataRoute) // get arTx data or bundleItem data + v1.GET("/:id", s.dataRoute) // get arTx data or bundleItem data + v1.HEAD("/:id", s.dataRoute) // get arTx data or bundleItem data + v1.GET("/bridge/:id", s.dataBridgeToArio) // bridge to ario + v1.HEAD("/bridge/:id", s.dataBridgeToArio) // bridge to ario + if s.EnableManifest { v1.POST("/manifest_url/:id", s.setManifestUrl) } @@ -743,6 +747,18 @@ func (s *Arseeding) bundleFees(c *gin.Context) { c.JSON(http.StatusOK, s.bundlePerFeeMap) } +func (s *Arseeding) dataBridgeToArio(c *gin.Context) { + txId := c.Param("id") + tags, data, err := getArTxOrItemData(txId, s.store) + if err != nil { + c.JSON(http.StatusNotFound, "Not Found") + return + } + contentLength := len(data) + c.Header("x-content-length", strconv.Itoa(contentLength)) + c.Data(200, fmt.Sprintf("%s; charset=utf-8", getTagValue(tags, schema.ContentType)), data) +} + func (s *Arseeding) dataRoute(c *gin.Context) { txId := c.Param("id") tags, data, err := getArTxOrItemData(txId, s.store) diff --git a/middleware.go b/middleware.go index ef0e808..df80218 100644 --- a/middleware.go +++ b/middleware.go @@ -58,7 +58,7 @@ func CORSMiddleware() gin.HandlerFunc { c.Writer.Header().Set("Access-Control-Allow-Origin", "*") c.Writer.Header().Set("Access-Control-Allow-Credentials", "true") c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With") - c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT") + c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT, HEAD") if c.Request.Method == "OPTIONS" { c.AbortWithStatus(204) diff --git a/schema/api.go b/schema/api.go index b1fcebb..ff985d7 100644 --- a/schema/api.go +++ b/schema/api.go @@ -5,9 +5,9 @@ import ( ) const ( - AllowMaxItemSize = 200 * 1024 * 1024 // 200 MB + AllowMaxItemSize = 500 * 1024 * 1024 // 500 MB AllowMaxNativeDataSize = 500 * 1024 * 1024 // 500 MB - AllowMaxRespDataSize = 50 * 1024 * 1024 // 50 MB + AllowMaxRespDataSize = 500 * 1024 * 1024 // 500 MB ) type RespOrder struct {