Hot questions for Using Vapor in perfect


I recently made the switch from Perfect to Vapor.In Perfect you could do something like this without using a html file.

routes.add(method: .get, uri: "/", handler: {
    request, response in
    response.setHeader(.contentType, value: "text/html")
    response.appendBody(string: "<html><img src=></html>")

In Vapor the only way I found to return the html is to do this.How could I return html code without using a html file in vapor?

 drop.get("/") { request in
    return try drop.view.make("somehtmlfile.html")


You can build your own Response, avoiding views completely.

drop.get { req in
  return Response(status: .ok, headers: ["Content-Type": "text/html"], body: "<html><img src=></html>")


drop.get { req in
  let response = Response(status: .ok, body: "<html><img src=></html>")
  response.headers["Content-Type"] = "text/html"
  return response