Created
July 17, 2014 08:10
-
-
Save erhangundogan/0696d85dd0bae3e7ceab to your computer and use it in GitHub Desktop.
simple go http server
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 | |
| import ( | |
| "fmt" | |
| "net/http" | |
| "strings" | |
| ) | |
| var chttp = http.NewServeMux() | |
| func main() { | |
| chttp.Handle("/", http.FileServer(http.Dir("./"))) | |
| http.HandleFunc("/erhan", HomeHandler) | |
| http.ListenAndServe(":8080", nil) | |
| } | |
| func HomeHandler(w http.ResponseWriter, r *http.Request) { | |
| if (strings.Contains(r.URL.Path, ".")) { | |
| chttp.ServeHTTP(w, r) | |
| } else { | |
| fmt.Fprintf(w, "HomeHandler") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment