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 (
66 "net/http"
77
88 "github.com/gorilla/mux"
9+ "github.com/play-with-docker/play-with-docker/storage"
910)
1011
12+ type PublicUserInfo struct {
13+ Id string `json:"id"`
14+ Avatar string `json:"avatar"`
15+ Name string `json:"name"`
16+ }
17+
1118func GetUser (rw http.ResponseWriter , req * http.Request ) {
1219 vars := mux .Vars (req )
1320 userId := vars ["userId" ]
1421
1522 u , err := core .UserGet (userId )
1623 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+ }
1729 log .Println (err )
1830 rw .WriteHeader (http .StatusInternalServerError )
1931 return
2032 }
2133
22- json .NewEncoder (rw ).Encode (u )
34+ pui := PublicUserInfo {Id : u .Id , Avatar : u .Avatar , Name : u .Name }
35+ json .NewEncoder (rw ).Encode (pui )
2336}
You can’t perform that action at this time.
0 commit comments