Skip to content

Commit

Permalink
Merge pull request #62 from everFinance/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
zyjblockchain authored Jan 26, 2023
2 parents d777ad6 + 1534128 commit 8e0e8f1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
18 changes: 17 additions & 1 deletion api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions schema/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8e0e8f1

Please sign in to comment.