Hello. I'm using the go language in Google App Engine. I'm having trouble getting the logged-in user's information. Similarly, the login URL and logout URL cannot be obtained. All nil will be returned. user.IsAdmin (c) returns false. please help me.
admin.go
func Entry(w http.ResponseWriter, r *http.Request) {
...
c := appengine.NewContext(r)
inUrl, err := user.LoginURL(c, "/admin/top/")
...
}
func AdminTop(w http.ResponseWriter, r *http.Request) {
...
c := appengine.NewContext(r)
booisadmin := user.IsAdmin(c)
u := user.Current(c)
outUrl, err := user.LogoutURL(c, "/")
...
}
app.yaml
runtime: go116
app_engine_apis: true
handlers:
- url: /assets/css
mime_type: text/css
static_dir: assets/css
- url: /assets/html
mime_type: text/html
static_dir: assets/html
- url: /assets/img
static_dir: assets/img
- url: /admin/.*
login: require
script: _go_app
- url: /.*
script: _go_app