Created
May 19, 2016 11:24
-
-
Save tuxlinuxien/48abdfbd4f5a1cda1c151edad07d7e78 to your computer and use it in GitHub Desktop.
simple golang htt2 server ( go >= 1.6)
This file contains hidden or 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 | |
/* | |
** generate certifictes: | |
** $> openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pem | |
** [...] | |
** Country Name (2 letter code) [AU]:CN | |
** State or Province Name (full name) [Some-State]: | |
** Locality Name (eg, city) []: | |
** Organization Name (eg, company) [Internet Widgits Pty Ltd]: | |
** Organizational Unit Name (eg, section) []: | |
** Common Name (e.g. server FQDN or YOUR name) []:localhost:8080 <---- IMPORTANT! | |
** Email Address []: | |
** | |
*/ | |
import ( | |
"fmt" | |
"net/http" | |
) | |
func handler(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hi there!") | |
} | |
func main() { | |
http.HandleFunc("/", handler) | |
http.ListenAndServeTLS(":8080", "cert.pem", "key.pem", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment