Skip to content

Instantly share code, notes, and snippets.

@tamx
Last active July 20, 2017 09:34
Show Gist options
  • Save tamx/fc15360f9710c48cb7e9f8cf73b80096 to your computer and use it in GitHub Desktop.
Save tamx/fc15360f9710c48cb7e9f8cf73b80096 to your computer and use it in GitHub Desktop.
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