func (self HttpBasicAuthenticator) AuthHandler(next http.Handler) http.Handler {
	if self.HttpAuthenticable == nil {
		panic("HttpAuthenticable cannot be nil")
	}

	f := func(w http.ResponseWriter, r *http.Request) {
		user, secret := self.parseAuthHeader(r.Header.Get("Authorization"))
		if len(user) > 0 &&
			len(secret) > 0 &&
			self.TryAuthentication(r, user, secret) {
			next.ServeHTTP(w, r)
			return
		}

		HttpHeader_WwwAuthenticate().
			SetValue(BASIC_REALM).
			SetWriter(w.Header())
		http.Error(w, http.StatusText(http.StatusUnauthorized),
			http.StatusUnauthorized)
	}

	return http.HandlerFunc(f)
}
func (self HttpBasicAuthenticator) AuthHandler(next http.Handler) http.Handler {
	if self.HttpAuthenticable == nil {
		panic("HttpAuthenticable cannot be nil")
	}

	f := func(w http.ResponseWriter, r *http.Request) {
		user, secret := self.parseAuthHeader(r.Header.Get("Authorization"))
		if len(user) > 0 &&
			len(secret) > 0 &&
			self.TryAuthentication(r, user, secret) {
			next.ServeHTTP(w, r)
			return
		}

		HttpHeader_WwwAuthenticate().
			SetValue(BASIC_REALM).
			SetWriter(w.Header())
		http.Error(w, http.StatusText(http.StatusUnauthorized),
			http.StatusUnauthorized)
	}

	return http.HandlerFunc(f)
}
// AuthHandler is a HTTP request middleware that enforces authentication.