Last active
July 6, 2017 05:45
-
-
Save kevburnsjr/39d7233ec21989c4bb2b50ad95f6788b to your computer and use it in GitHub Desktop.
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
import ( | |
"./controller" | |
"net/http" | |
) | |
var routes = map[string]func(http.ResponseWriter, *http.Request){ | |
"/": controller.Index, | |
"/acct": controller.Acct, | |
"/acct/auth": controller.AcctAuth, | |
// etc... | |
} | |
func ServeHttp(w http.ResponseWriter, r *http.Request) { | |
if handler, ok := routes[r.URL.Path]; ok { | |
handler(w, r) | |
} else { | |
http.Error(w, "Not Found : "+r.URL.Path, 404) | |
return | |
} | |
} | |
func main() { | |
http.ListenAndServe(":80", http.HandlerFunc(ServeHttp)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment