Exemplo n.º 1
0
func login(w http.ResponseWriter, r *http.Request) {
	err := loginTemplate.ExecuteTemplate(w, "base", Page{"Login"})
	if err != nil {
		log.Println("error rendering template", err)
		response.InternalServerError(w)
	}
}
Exemplo n.º 2
0
func auth(w http.ResponseWriter, r *http.Request) {
	username, password, ok := r.BasicAuth()
	if !ok {
		response.Forbidden(w)
		return
	}

	instapaperClient := instapaper.New(username, password)
	ok, err := instapaperClient.Authenticate()
	if err != nil {
		response.InternalServerError(w)
		return
	}

	if ok {
		response.OK(w)
		return
	}

	response.Forbidden(w)
}