Skip to content

Commit

Permalink
feat(): compatible old manifest url
Browse files Browse the repository at this point in the history
  • Loading branch information
zyjblockchain committed Aug 23, 2022
1 parent db26fb0 commit ae85103
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@ func ManifestMiddleware(wdb *Wdb, store *Store) gin.HandlerFunc {
return func(c *gin.Context) {
prefixUri := getRequestSandbox(c.Request.Host)
if len(prefixUri) > 0 && c.Request.Method == "GET" {
// compatible url https://xxxxxxx.arseed.web3infra.dev/{{arId}}
txId := getTxIdFromPath(c.Request.RequestURI)
if txId != "" && prefixUri == expectedTxSandbox(txId) {
protocol := "https"
if c.Request.TLS == nil {
protocol = "http"
}
// redirect url: https://arseed.web3infra.dev/{{arId}}
rootHost := strings.SplitN(c.Request.Host, ".", 2)[1]
redirectUrl := fmt.Sprintf("%s://%s/%s", protocol, rootHost, txId)
c.Redirect(302, redirectUrl)

c.Abort()
return
}

mfId, err := wdb.GetManifestId(prefixUri)
if err != nil {
c.Next()
Expand Down

0 comments on commit ae85103

Please sign in to comment.