Slide 25
Slide 25 text
Ճͯ͠ΈΑ͏
func handleSecret(w http.ResponseWriter, r *http.Request)
{
user, password, _ := r.BasicAuth(
)
if user != "user" || password != "password"
{
w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`
)
http.Error(w, "ೝূʹࣦഊ͠·ͨ͠", http.StatusUnauthorized
)
retur
n
}
log.Printf("%s %s", r.Method, r.RequestURI
)
w.Write([]byte("ൿີͷϖʔδͰ͢ʂ")
)
}
http.HandleFunc("/", handleHome)
http.HandleFunc("/secret", handleSecret) // Ճ
log.Printf("ϙʔτ %s Ͱͪड͚Λ։࢝͠·͢...", port)
NBJOHPͷNBJO
ͷதʹՃ
NBJOHPʹՃ