Skip to content

Commit dd397ce

Browse files
committed
refactor: simplify route definitions by directly mapping endpoints to parameters
1 parent a365bc9 commit dd397ce

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

internal/router/router.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package router
22

33
import (
4-
"fmt"
54
"github.com/kataras/iris/v12"
65
"github.com/scutrobotlab/rm-schedule/internal/common"
76
"github.com/scutrobotlab/rm-schedule/internal/handler"
@@ -45,10 +44,9 @@ func Router(r *iris.Application, frontend string) {
4544
api.Get("/static/*path", handler.RMStaticHandler)
4645
api.Get("/mp/match", handler.MpMatchHandler)
4746
api.Get("/rank", handler.RankListHandler)
48-
49-
for name, param := range Params {
50-
api.Get(fmt.Sprintf("/%s", name), handler.RouteHandlerFactory(param))
51-
}
47+
api.Get("/group_rank_info", handler.RouteHandlerFactory(Params[common.UpstreamNameGroupRankInfo]))
48+
api.Get("/robot_data", handler.RouteHandlerFactory(Params[common.UpstreamNameRobotData]))
49+
api.Get("/schedule", handler.RouteHandlerFactory(Params[common.UpstreamNameSchedule]))
5250

5351
r.HandleDir("/", iris.Dir(frontend), iris.DirOptions{
5452
IndexName: "index.html",

0 commit comments

Comments
 (0)