In order to run this server, you'll need Swift 3 installed on your machine. If you're using a Mac, you already have everything you need. Otherwise follow Apple's instructions to install Swift before continuing.
You'll also need the latest Xcode installed. This is not a hard-fast requirement, but it does allow for easier debugging.
Once you have Swift installed, run the following commands in a terminal
$ cd /path/to/where/you/cloned/this/repo
$ swift package generate-xcodeproj
This will download Perfect and all its necessary dependencies to run the application. Once you've installed all the necessary dependencies, open the Xcode project file generated by the Swift Package Manager. You'll need to edit the scheme and set the working directory for the project. You can do this by selecting the terminal scheme and clicking on Edit Scheme -> Run -> Options -> Use custom working directory:
and clicking on the folder icon to select the root of this project (where the project file is).
Finally, select the terminal scheme and run the server. You should see [INFO] Starting HTTP server on 0.0.0.0:8080
printed to the console if everything is setup correctly.
There are 2 existing endpoints:
Given the correct username, returns the "authorization key" to be used on subsequent requests.
Parameter | Expected Value |
---|---|
username | the user you wish to have logged in |
{
"username": "matt"
}
{
"accessKey": "FB919310-6D87-4B49-B37F-222E1693C754"
}
Returns an image, as Data. This endpoint does require the Authorization
header -- use the token returned by the v1/key
endpoint
None.