(app *App, w http.ResponseWriter, r *http.Request)
| 685 | } |
| 686 | |
| 687 | func viewMeAPI(app *App, w http.ResponseWriter, r *http.Request) error { |
| 688 | reqJSON := IsJSON(r) |
| 689 | uObj := struct { |
| 690 | ID int64 `json:"id,omitempty"` |
| 691 | Username string `json:"username,omitempty"` |
| 692 | }{} |
| 693 | var err error |
| 694 | |
| 695 | if reqJSON { |
| 696 | _, uObj.Username, err = app.db.GetUserDataFromToken(r.Header.Get("Authorization")) |
| 697 | if err != nil { |
| 698 | return err |
| 699 | } |
| 700 | } else { |
| 701 | u := getUserSession(app, r) |
| 702 | if u == nil { |
| 703 | return impart.WriteSuccess(w, uObj, http.StatusOK) |
| 704 | } |
| 705 | uObj.Username = u.Username |
| 706 | } |
| 707 | |
| 708 | return impart.WriteSuccess(w, uObj, http.StatusOK) |
| 709 | } |
| 710 | |
| 711 | func viewMyPostsAPI(app *App, u *User, w http.ResponseWriter, r *http.Request) error { |
| 712 | reqJSON := IsJSON(r) |
nothing calls this directly
no test coverage detected