swisspol/GCDWebServer

Send response body for 404.

Closed this issue · 1 comments

Hello!

I've created a web server that serves a static website. A 404 response is sent if a request is made to a page that doesn't exist, but the response body is blank. This means that the WKWebView will be blank. Is there a way to send a simple "Not found" as a response body when returning 404s?

let secondServer = GCDWebServer()
secondServer.addGETHandler(forBasePath: "/", directoryPath: pages, indexFilename: "index.html", cacheAge: 3600, allowRangeRequests: true)
secondServer.start(withPort: 8080, bonjourName: nil)

addGETHandler() doesn't allow customizing 404 page, but it's just a wrapper around basic functions. You would need to write your own implementation of addGETHandler().