github.com/wanliu/go-oauth2-server@v0.0.0-20180817021415-f928fa1580df/web/index.go (about) 1 package web 2 3 import ( 4 // "fmt" 5 "net/http" 6 // "net/url" 7 // "path" 8 // "strings" 9 10 "github.com/wanliu/go-oauth2-server/models" 11 ) 12 13 func (s *Service) index(w http.ResponseWriter, r *http.Request) { 14 var ( 15 currentUser *models.OauthUser 16 username string 17 ) 18 19 // Get the session service from the request context 20 sessionService, err := getSessionService(r) 21 if err == nil { 22 session, err := sessionService.GetUserSession() 23 if err == nil { 24 currentUser, _ = s.GetOauthService().FindUserByUsername(session.Username) 25 username = session.Username 26 } 27 } 28 29 // Render the template 30 renderTemplate(w, "index.html", map[string]interface{}{ 31 "currentUser": currentUser, 32 "username": username, 33 }) 34 }