Last active
July 20, 2017 09:34
-
-
Save tamx/fc15360f9710c48cb7e9f8cf73b80096 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
| package center | |
| import ( | |
| "fmt" | |
| "net/http" | |
| "github.com/tamx/golang-digest" | |
| "google.golang.org/appengine" | |
| "google.golang.org/appengine/log" | |
| ) | |
| func init() { | |
| http.HandleFunc("/", | |
| digest.NewDigestAuth(CheckPassword, Logger).HandleFunc) | |
| } | |
| func CheckPassword(username string) string { | |
| if username == "tam" { | |
| return "test" | |
| } | |
| return "" | |
| } | |
| func Logger(w http.ResponseWriter, r *http.Request) { | |
| ctx := appengine.NewContext(r) | |
| log.Infof(ctx, "Requested URL: %v", r.URL) | |
| fmt.Fprintf(w, "Hello.") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment