Beispiel #1
0
func Auth(h http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		user := model.CurrentUser(r)

		if user != nil {
			h.ServeHTTP(w, r)
			return
		}

		w.WriteHeader(http.StatusUnauthorized)
	})
}
Beispiel #2
0
func GetMeHandler(w http.ResponseWriter, r *http.Request) {
	user := model.CurrentUser(r)
	httpres.Json(w, http.StatusOK, UserResponse{*user})
}