Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
whats-this
api
Commits
978d45c2
Commit
978d45c2
authored
6 years ago
by
Dean
Browse files
Options
Downloads
Patches
Plain Diff
version 1.6.1: fix /users/me to be backwards compatible
parent
bed9a54a
No related branches found
Branches containing commit
Tags
v1.6.1
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/routes/me.go
+25
-1
25 additions, 1 deletion
lib/routes/me.go
main.go
+1
-1
1 addition, 1 deletion
main.go
with
26 additions
and
2 deletions
lib/routes/me.go
+
25
−
1
View file @
978d45c2
...
...
@@ -9,6 +9,23 @@ import (
"github.com/go-chi/render"
)
// meResponse is the response type for /users/me.
type
meResponse
struct
{
Success
bool
`json:"success"`
StatusCode
*
int
`json:"errorcode"`
User
meUser
`json:"user"`
}
// meUser is a modified version of db.User for /users/me to maintain
// compatibility with the original version of the route.
type
meUser
struct
{
UserID
string
`json:"user_id"`
Username
string
`json:"username"`
Email
string
`json:"email"`
IsAdmin
bool
`json:"is_admin"`
IsBlocked
bool
`json:"is_blocked"`
}
// Me handles /users/me requests.
func
Me
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
// Only authorized users can use this route
...
...
@@ -18,7 +35,14 @@ func Me(w http.ResponseWriter, r *http.Request) {
}
// Return response
u
:=
meUser
{
UserID
:
user
.
ID
,
Username
:
user
.
Username
,
Email
:
user
.
Email
,
IsAdmin
:
user
.
IsAdmin
,
IsBlocked
:
user
.
IsBlocked
,
}
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
WriteHeader
(
http
.
StatusOK
)
render
.
JSON
(
w
,
r
,
user
)
render
.
JSON
(
w
,
r
,
meResponse
{
true
,
nil
,
u
}
)
}
This diff is collapsed.
Click to expand it.
main.go
+
1
−
1
View file @
978d45c2
...
...
@@ -25,7 +25,7 @@ import (
const
(
configLocationUnix
=
"/etc/whats-this/api/config.toml"
shutdownTimeout
=
10
*
time
.
Second
version
=
"1.6.
0
"
version
=
"1.6.
1
"
)
// printConfiguration iterates through a configuration map[string]interface{}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment