Created
January 31, 2017 17:06
-
-
Save peeyushsrj/0c4b11cc21c75fb08106790f7cb8cee2 to your computer and use it in GitHub Desktop.
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" | |
// "io" | |
"net/http" | |
"log" | |
) | |
func HelloServer(w http.ResponseWriter, req *http.Request) { | |
w.Header().Set("Content-Type", "text/plain") | |
w.Write([]byte("This is an example server.\n")) | |
// fmt.Fprintf(w, "This is an example server.\n") | |
// io.WriteString(w, "This is an example server.\n") | |
} | |
func main() { | |
http.HandleFunc("/hello", HelloServer) | |
err := http.ListenAndServeTLS(":443", "server.crt", "server.key", nil) | |
if err != nil { | |
log.Fatal("ListenAndServe: ", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment