init project

This commit is contained in:
LeeShuang
2021-12-08 23:43:14 +08:00
commit 2f72bfa946
19 changed files with 677 additions and 0 deletions

19
api/middlewares.go Normal file
View File

@@ -0,0 +1,19 @@
package api
import (
"memos/common/error"
"net/http"
)
func AuthCheckerMiddleWare(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
userId, err := GetUserIdInCookie(r)
if err != nil || userId == "" {
error.ErrorHandler(w, "NOT_AUTH")
return
}
next.ServeHTTP(w, r)
})
}