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.

Requirements

  • Swift >= 4.0 + CoreFoundation + Foundation
  • macOS >= 10.12 or Linux
  • HTTP server software (e.g. Apache or similar software)

Usage

import Foundation
import CGIResponder

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

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

git clone https://github.com/YOCKOW/SwiftCGIResponder.git
cd SwiftCGIResponder
./build-install.rb --install-prefix=/path/to/your/system --install
cd ~/your/project
swiftc main.swift -I/path/to/your/system/include -L/path/to/your/system/lib -lSwiftCGIResponder

... or you can also use Swift Package Manager easily to import CGIResponder to your project.

License

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

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Releases

0.1.0-dev20171108 - Nov 8, 2017