File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -6,18 +6,31 @@ import (
6
6
"net/http"
7
7
8
8
"github.com/gorilla/mux"
9
+ "github.com/play-with-docker/play-with-docker/storage"
9
10
)
10
11
12
+ type PublicUserInfo struct {
13
+ Id string `json:"id"`
14
+ Avatar string `json:"avatar"`
15
+ Name string `json:"name"`
16
+ }
17
+
11
18
func GetUser (rw http.ResponseWriter , req * http.Request ) {
12
19
vars := mux .Vars (req )
13
20
userId := vars ["userId" ]
14
21
15
22
u , err := core .UserGet (userId )
16
23
if err != nil {
24
+ if storage .NotFound (err ) {
25
+ log .Printf ("User with id %s was not found\n " , userId )
26
+ rw .WriteHeader (http .StatusNotFound )
27
+ return
28
+ }
17
29
log .Println (err )
18
30
rw .WriteHeader (http .StatusInternalServerError )
19
31
return
20
32
}
21
33
22
- json .NewEncoder (rw ).Encode (u )
34
+ pui := PublicUserInfo {Id : u .Id , Avatar : u .Avatar , Name : u .Name }
35
+ json .NewEncoder (rw ).Encode (pui )
23
36
}
You can’t perform that action at this time.
0 commit comments