Swiftpack.co - Package - YOCKOW/SwiftCGIResponder

What is SwiftCGIResponder?

SwiftCGIResponder will provide miscellaneous functions you may use when you write CGI programs in Swift.
It's an experimental library under development, and useless as of now.


  • Swift 4.2, 4.1 compatibility mode of 4.2
    • CoreFoundation
    • Foundation
  • macOS >= 10.12 or Linux
  • HTTP server software (e.g. Apache or similar software)



import CGIResponder

var responder = CGIResponder()
responder.status = .ok
responder.contentType = ContentType(pathExtension:.txt, parameters:["charset":"UTF-8"])!
responder.content = .string("Hello, World!\n", encoding:.utf8)
try! responder.respond()

// -- Output --
// Status: 200 OK
// Content-Type: text/plain; charset=UTF-8
// Hello, World!

You may see other samples in SwiftCGIResponderSamples.

How to install

You can use Swift Package Manager easily to import CGIResponder to your project.


MIT License.
See "LICENSE.txt" for more information.