WebAppContaining

public protocol WebAppContaining: class

Class protocol containing the WebApp that responds to the incoming HTTP requests. The following is an example of a WebApp that returns the request as a response:

   class EchoWebApp: WebAppContaining {
       func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
           res.writeHeader(status: .ok, headers: [:])
           return .processBody { (chunk, stop) in
               switch chunk {
               case .chunk(let data, let finishedProcessing):
                   res.writeBody(data) { _ in
                       finishedProcessing()
                   }
               case .end:
                   res.done()
               default:
                   stop = true
                   res.abort()
               }
           }
       }
   }