mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-18 08:26:45 +02:00
22 lines
330 B
Go
22 lines
330 B
Go
|
package client
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
currentUserUrl = "/user"
|
||
|
)
|
||
|
|
||
|
func (c *Client) CurrentUser() (User, error) {
|
||
|
url, opaque := c.ResourceUrl(currentUserUrl, nil, nil)
|
||
|
var user User
|
||
|
|
||
|
contents, err := c.Do("GET", url, opaque, nil)
|
||
|
if err == nil {
|
||
|
err = json.Unmarshal(contents, &user)
|
||
|
}
|
||
|
|
||
|
return user, err
|
||
|
}
|