Skip to content

mdiasdev/PerfectServerDemo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perfect Server Demo

Project Requirements

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.

Setup

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.

API Spec v1

There are 2 existing endpoints:

POST v1/key

Given the correct username, returns the "authorization key" to be used on subsequent requests.

Parameters

Parameter Expected Value
username the user you wish to have logged in

Example Request

POST http://localhost:8080/v1/key

{
   "username": "matt"
}

Example Response

{
"accessKey": "FB919310-6D87-4B49-B37F-222E1693C754"
}

GET v1/image

Returns an image, as Data. This endpoint does require the Authorization header -- use the token returned by the v1/key endpoint

Parameters

None.

Example Request

GET http://localhost:8080/v1/image

Example Response

logo

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages