diff --git a/app/start.go b/app/start.go index 4f5a46e..fe1ac73 100644 --- a/app/start.go +++ b/app/start.go @@ -28,6 +28,7 @@ func Start(conf common.Conf, db *sql.DB) { // Read privilege required gv1.GET("/users/id/:id", Method(v1.UserByIDGET, db, common.PrivilegeRead)) gv1.GET("/users/name/:name", Method(v1.UserByNameGET, db, common.PrivilegeRead)) + gv1.GET("/users/self", Method(v1.UserSelfGET, db, common.PrivilegeRead)) gv1.GET("/badges", Method(v1.BadgesGET, db, common.PrivilegeRead)) gv1.GET("/badges/:id", Method(v1.BadgeByIDGET, db, common.PrivilegeRead)) } diff --git a/app/v1/user.go b/app/v1/user.go index 30a3ce6..527ac61 100644 --- a/app/v1/user.go +++ b/app/v1/user.go @@ -8,6 +8,7 @@ import ( "strings" "time" + "github.com/gin-gonic/gin" "github.com/osuripple/api/common" ) @@ -113,3 +114,12 @@ func userPuts(md common.MethodData, row *sql.Row) (r common.Response) { r.Data = user return } + +// UserSelfGET is a shortcut for /users/id/self. (/users/self) +func UserSelfGET(md common.MethodData) common.Response { + md.C.Params = append(md.C.Params, gin.Param{ + Key: "id", + Value: "self", + }) + return UserByIDGET(md) +}