swifter icon indicating copy to clipboard operation
swifter copied to clipboard

allow root route to be dynamic

Open derek-baxter opened this issue 4 years ago • 0 comments

Hi,

I currently this snippet

serverInstance["/mobile"] = {
            request in {
                
                print("In Mobile")
                
                var html = "Hello World!"
                
                if let indexURL = Bundle.main.url(forResource: "index",
                                                  withExtension: "html",
                                                  subdirectory: "app") {
                   
                    do{
                    html = try String(contentsOf: indexURL)
                    } catch {
                    }
                    
                }
                
                return HttpResponse.ok(.text(html))
            }()

How is it possible to so when the server is running, if I goto anything beneath mobile. the server would load the same file? ex localhost:8080/mobile/test

would be caught in the above snippet

derek-baxter avatar Aug 27 '21 18:08 derek-baxter