mirror of
https://github.com/hamburghammer/gohttpserver.git
synced 2024-12-22 22:47:41 +01:00
27 lines
593 B
Go
27 lines
593 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
func handleOauth2() {
|
|
http.HandleFunc("/-/user", func(w http.ResponseWriter, r *http.Request) {
|
|
fullNameMap, _ := url.ParseQuery(r.Header.Get("X-Auth-Request-Fullname"))
|
|
var fullName string
|
|
for k := range fullNameMap {
|
|
fullName = k
|
|
break
|
|
}
|
|
user := &UserInfo{
|
|
Email: r.Header.Get("X-Auth-Request-Email"),
|
|
Name: fullName,
|
|
NickName: r.Header.Get("X-Auth-Request-User"),
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
data, _ := json.Marshal(user)
|
|
w.Write(data)
|
|
})
|
|
}
|