A Simple REST server using Swift 5.0.1 on Ubuntu 18.04.
//bash
mkdir RestKitura
cd RestKitura
swift package init --type executable
//bash
swift test
The output:
[3/3] Linking ./.build/x86_64-unknown-linux/debug/RestKituraPackageTests.xctest
Test Suite 'All tests' started at 2019-06-13 11:19:09.478
Test Suite 'debug.xctest' started at 2019-06-13 11:19:09.501
Test Suite 'QuickSpec' started at 2019-06-13 11:19:09.501
Test Case 'QuickSpec.Vanilla tests, Test that Quick and Nimble are setup, True is always true' started at 2019-06-13 11:19:09.501
Test Case 'QuickSpec.Vanilla tests, Test that Quick and Nimble are setup, True is always true' passed (0.001 seconds)
Test Case 'QuickSpec.Vanilla tests, Test that Quick and Nimble are setup, false is always false' started at 2019-06-13 11:19:09.502
Test Case 'QuickSpec.Vanilla tests, Test that Quick and Nimble are setup, false is always false' passed (0.0 seconds)
Test Case 'QuickSpec.Vanilla tests, Test that Quick and Nimble are setup, false is not true' started at 2019-06-13 11:19:09.502
Test Case 'QuickSpec.Vanilla tests, Test that Quick and Nimble are setup, false is not true' passed (0.0 seconds)
Test Case 'QuickSpec.Vanilla tests, Test that Quick and Nimble are setup, true is not false' started at 2019-06-13 11:19:09.502
Test Case 'QuickSpec.Vanilla tests, Test that Quick and Nimble are setup, true is not false' passed (0.0 seconds)
Test Suite 'QuickSpec' passed at 2019-06-13 11:19:09.502
Executed 4 tests, with 0 failures (0 unexpected) in 0.001 (0.001) seconds
Test Suite 'debug.xctest' passed at 2019-06-13 11:19:09.502
Executed 4 tests, with 0 failures (0 unexpected) in 0.001 (0.001) seconds
Test Suite 'All tests' passed at 2019-06-13 11:19:09.502
Executed 4 tests, with 0 failures (0 unexpected) in 0.001 (0.001) seconds
//bash
swift run
The output:
[2/2] Linking ./.build/x86_64-unknown-linux/debug/RestKitura
[2019-06-13T11:31:13.344-04:00] [VERBOSE] [Kitura.swift:160 run()] Starting Kitura framework...
[2019-06-13T11:31:13.354-04:00] [VERBOSE] [Kitura.swift:177 start()] Starting an HTTP Server on port 8080...
[2019-06-13T11:31:13.354-04:00] [INFO] [HTTPServer.swift:237 listen(_:)] Listening on port 8080
[2019-06-13T11:31:13.354-04:00] [VERBOSE] [HTTPServer.swift:238 listen(_:)] Options for port 8080: maxPendingConnections: 100, allowPortReuse: false
or by using Curl in another terminal:
//bash
curl http://localhost:8080/
The output:
Hello world
The server log for each request:
[2019-06-13T11:35:18.420-04:00] [VERBOSE] [HTTPServerRequest.swift:333 parsingCompleted()] HTTP request from=192.168.56.102; proto=http;
[2019-06-13T11:35:18.597-04:00] [VERBOSE] [HTTPServerRequest.swift:333 parsingCompleted()] HTTP request from=192.168.56.102; proto=http;
[2019-06-13T11:40:36.725-04:00] [VERBOSE] [HTTPServerRequest.swift:333 parsingCompleted()] HTTP request from=127.0.0.1; proto=http;
link |
Stars: 0 |
Last commit: 4 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics