+ use("/feedback/stars/:id/dimension/:dimension", new APIStarsDimension(config))
+ end
+end
+
+# Base handler for feedback features.
+abstract class APIFeedBack
+ super APIHandler
+
+ # Get the user logged in or null if no session
+ fun get_session_user(req: HttpRequest): nullable User do
+ var session = req.session
+ if session == null then return null
+ return session.user
+ end
+
+ # Get the login of the session user or null if no session
+ fun get_session_login(req: HttpRequest): nullable String do
+ var user = get_session_user(req)
+ if user == null then return null
+ return user.login
+ end
+end
+
+# Most rated entities
+class APIStarsMost
+ super APIFeedBack
+
+ redef fun get(req, res) do
+ res.json new JsonArray.from(config.stars.most_rated)
+ end
+end
+
+# Best rated entities
+class APIStarsBest
+ super APIFeedBack
+
+ redef fun get(req, res) do
+ res.json new JsonArray.from(config.stars.best_rated)
+ end
+end
+
+# Best rated entities
+class APIStarsWorst
+ super APIFeedBack
+
+ redef fun get(req, res) do
+ res.json new JsonArray.from(config.stars.worst_rated)
+ end
+end
+
+# Best rated entities
+class APIStarsUsers
+ super APIFeedBack
+
+ redef fun get(req, res) do
+ res.json new JsonArray.from(config.stars.users_ratings)
+ end
+end
+
+# Stars attributed to mentities by user
+class APIUserStars
+ super APIFeedBack
+
+ redef fun get(req, res) do
+ var user = get_session_user(req)
+ if user == null then return
+ res.json new JsonArray.from(user.ratings(config))