0

In My Serverside swift demo, I have Redirecting to the Client. It's moved permenantly. How can I cancel redirection. I have used below code to redirect request.

response.status = .movedPermanently
response.setHeader(.location, value: "http://www.perfect.org/")
response.completed()

Right now i am not able to cancel or not call another function. Is there any way to remove redirect request?

Vvk
  • 4,031
  • 29
  • 51

1 Answers1

1

the PerfectTemplate project: https://github.com/PerfectlySoft/PerfectTemplate.git has already demonstrated your case: https://github.com/PerfectlySoft/PerfectTemplate/blob/master/Sources/main.swift#L73

"routes":[
            ["method":"get", "uri":"/**", 
            "handler":PerfectHTTPServer.HTTPHandler.redirect,
             "base":"http://localhost:\(port1)"]
        ]

which means that all requests upon the the current server will be forwarded to the base url.

ChrisF
  • 134,786
  • 31
  • 255
  • 325
PerfectlyRock
  • 405
  • 2
  • 7