Forked from pallavtrivedi03/FlightsListController.swift
Created
February 11, 2022 18:17
-
-
Save EvolverSwiftUI/6e6afa8b2eefbb39effd20a87bc9a32b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import PerfectLib | |
import PerfectHTTP | |
import PerfectHTTPServer | |
class FlightsListController { | |
func handleFlightsListRequest(request: HTTPRequest, response: HTTPResponse) { | |
do { | |
try response.setBody(json: getFlightsList()) | |
.setHeader(.contentType, value: "application/json") | |
.completed(status: .ok) | |
} catch { | |
response.setBody(string: "Something went wrong") | |
.completed(status: .internalServerError) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment