mirror of
https://github.com/usememos/memos.git
synced 2024-12-24 20:01:48 +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
|
|
}
|