示例#1
0
文件: auth.go 项目: icobani/stack
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)
	})
}
示例#2
0
文件: user.go 项目: icobani/stack
func GetMeHandler(w http.ResponseWriter, r *http.Request) {
	user := model.CurrentUser(r)
	httpres.Json(w, http.StatusOK, UserResponse{*user})
}