Add API handler for /users/self
This commit is contained in:
		| @@ -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)) | ||||
| 		} | ||||
|   | ||||
| @@ -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) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user