mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
update restful api
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"memos/common/error"
|
||||
"memos/api/e"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@ -10,10 +10,19 @@ func AuthCheckerMiddleWare(next http.Handler) http.Handler {
|
||||
userId, err := GetUserIdInCookie(r)
|
||||
|
||||
if err != nil || userId == "" {
|
||||
error.ErrorHandler(w, "NOT_AUTH")
|
||||
e.ErrorHandler(w, "NOT_AUTH", "Need authorize")
|
||||
return
|
||||
}
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func CorsMiddleWare(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user