Last active
August 29, 2015 14:25
-
-
Save kylemarsh/f638e8ae705868d28ad0 to your computer and use it in GitHub Desktop.
Hello World for running Go under FCGI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rename the binary created from hello-fcgi.go to "fcgitest.fcgi" | |
# chmod 755 fcgitest.fcgi | |
# Credit goes to http://www.dav-muz.net/blog/2013/09/how-to-use-go-and-fastcgi/ | |
RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d [OR] | |
RewriteCond %{REQUEST_URI} ^/$ | |
RewriteRule ^(.*)$ fcgitest.fcgi/$1 [QSA,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
"net/http/fcgi" | |
) | |
func hello(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintln(w, "Hello, World!") | |
} | |
func main() { | |
http.HandleFunc("/", hello) | |
fcgi.Serve(nil, nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment