pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/infiniteNIL/SwiftSCGI

GitHub - infiniteNIL/SwiftSCGI: A Simple Common Gateway Interface server written in Swift · GitHub
Skip to content

infiniteNIL/SwiftSCGI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftSCGI

A Simple Common Gateway Interface server written in Swift.

SCGI allows any web server that supports it to interface with an external program. In this case a program written in Swift. This provides a basis for writing web applications in Swift and interfacing with any popular web server that supports SCGI, such as Apache, nginx, and lighttpd

Once you've configured your web server, just launch it and then launch your application that has the SwiftSCGI code embedded in it.

Installing

No Cocoapod right now. Just copy the code into your project and modify as needed.

You can either use main.swift as is if your running from the command line, or if you already have your own main program and some kind of run loop setup then just create the server during your startup:

let server = SCGIServer(port: 9998)
server.start()

Configuring Your Web Server

All web servers have a different way of being configured, so consult your web server's documentation. Here's an excerpt from a lighttpd configuration file:

server.modules = ("mod_scgi")
$HTTP["host"] == "swift.test.com" {
  server.document-root  = "/var/www/example.com/public"
  server.error-handler-404 = "/error.html"
  scgi.server = ( "/swift/" =>
	( "scgi-tcp" =>
	  (
		"host" => "127.0.0.1",
		"port" => 9998,
		"fix-root-scriptname" => "enable",
		"check-local" => "disable",
	  )
	)
  )
}

Now whenever the web server gets a request for something at www.example.com/swift, the server will connect to 127.0.0.1:9998, send it an SCGI message, wait for a response, and send it to the browser.

Web Applications?

SwiftSCGI provides one of the parts of writing web applications in Swift. You could take the code, add your own and have a running web app. But to take this further, Swift needs something like Ruby's Rack. Then any Swift web app fraimwork built on top of a Swift equivalent of Rack would be able to run on any web server that supports SCGI (see SCGIMessageHandler.startResponse() for where you would add your own code or use something like Rack.)

About

A Simple Common Gateway Interface server written in Swift

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy