mirror of
https://github.com/usememos/memos.git
synced 2024-12-21 10:11:42 +03:00
24 lines
397 B
Go
24 lines
397 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
type Response struct {
|
|
Succeed bool `json:"succeed"`
|
|
Message string `json:"message"`
|
|
Data interface{} `json:"data"`
|
|
}
|
|
|
|
func GetUserIdInSession(r *http.Request) (string, error) {
|
|
session, _ := SessionStore.Get(r, "session")
|
|
|
|
userId, ok := session.Values["user_id"].(string)
|
|
|
|
if !ok {
|
|
return "", http.ErrNoCookie
|
|
}
|
|
|
|
return userId, nil
|
|
}
|