mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
init project
This commit is contained in:
19
api/middlewares.go
Normal file
19
api/middlewares.go
Normal 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)
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user