I’m writing the simplest server via Swift Express
And I want to add custom handler for “url not found” so that if user write “/notFoundUrl” he will see something like that: “Url “notFoundUrl” not found, please go to home page”.
I’ve added:
app.get("/:notFoundUrl+") { (request:Request<AnyContent>)->Action<AnyContent> in
print(request.params["notFoundUrl"])
return Action<AnyContent>.render("index", context: ["hello": "Page Not Found: " + request.params["notFoundUrl"]!])
}
But it’s not appropriate becouse:
- Order does matter.
- I can’t return 404 error.
So how to add custom “Page Not Found/404 handler” to Swift Express Server?
Aucun commentaire:
Enregistrer un commentaire