1
- use actix_web:: web;
1
+ use actix_web:: { web, HttpResponse } ;
2
2
3
3
use crate :: server:: {
4
4
internal_user,
@@ -8,7 +8,7 @@ use crate::server::{
8
8
delete_progress_reset_item,
9
9
} ,
10
10
user_submissions:: get_user_submission_count,
11
- auth:: get_token,
11
+ auth:: { Authentication , get_token} ,
12
12
language_count:: get_language_list,
13
13
problem_list:: {
14
14
add_item, create_list, delete_item, delete_list, get_own_lists, get_single_list, update_item, update_list,
@@ -21,8 +21,8 @@ use crate::server::{
21
21
get_users_time_submissions,
22
22
} ,
23
23
ranking:: {
24
- self , get_ac_ranking , get_language_ranking , get_streak_ranking , get_users_ac_rank ,
25
- get_users_language_rank , get_users_rated_point_sum_rank , get_users_streak_rank ,
24
+ RankingSelector , UserRankSelector , StreakRanking , AcRanking , RatedPointSumRanking ,
25
+ get_language_ranking , get_users_language_rank ,
26
26
} ,
27
27
virtual_contest:: {
28
28
create_contest, update_contest, update_items, get_single_contest,
@@ -31,76 +31,76 @@ use crate::server::{
31
31
}
32
32
} ;
33
33
34
- pub ( crate ) fn config_services ( cfg : & mut web:: ServiceConfig ) {
34
+ pub ( crate ) fn config_services < A : Authentication + Clone + Send + Sync + ' static > ( cfg : & mut web:: ServiceConfig ) {
35
35
log:: info!( "Configuring routes..." ) ;
36
36
cfg. service (
37
37
web:: scope ( "/internal-api" )
38
- . service ( web:: resource ( "/authorize" ) . route ( web:: get ( ) . to ( get_token) ) )
38
+ . service ( web:: resource ( "/authorize" ) . route ( web:: get ( ) . to ( get_token :: < A > ) ) )
39
39
. service (
40
40
web:: scope ( "/list" )
41
- . service ( web:: resource ( "/my" ) . route ( web:: get ( ) . to ( get_own_lists) ) )
42
- . service ( web:: resource ( "/get/{list_id}" ) . route ( web:: get ( ) . to ( get_single_list) ) )
43
- . service ( web:: resource ( "/create" ) . route ( web:: post ( ) . to ( create_list) ) )
44
- . service ( web:: resource ( "/delete" ) . route ( web:: post ( ) . to ( delete_list) ) )
45
- . service ( web:: resource ( "/update" ) . route ( web:: post ( ) . to ( update_list) ) )
41
+ . service ( web:: resource ( "/my" ) . route ( web:: get ( ) . to ( get_own_lists :: < A > ) ) )
42
+ . service ( web:: resource ( "/get/{list_id}" ) . route ( web:: get ( ) . to ( get_single_list :: < A > ) ) )
43
+ . service ( web:: resource ( "/create" ) . route ( web:: post ( ) . to ( create_list :: < A > ) ) )
44
+ . service ( web:: resource ( "/delete" ) . route ( web:: post ( ) . to ( delete_list :: < A > ) ) )
45
+ . service ( web:: resource ( "/update" ) . route ( web:: post ( ) . to ( update_list :: < A > ) ) )
46
46
. service (
47
47
web:: scope ( "/item" )
48
- . service ( web:: resource ( "/add" ) . route ( web:: post ( ) . to ( add_item) ) )
49
- . service ( web:: resource ( "/update" ) . route ( web:: post ( ) . to ( update_item) ) )
50
- . service ( web:: resource ( "/delete" ) . route ( web:: post ( ) . to ( delete_item) ) )
48
+ . service ( web:: resource ( "/add" ) . route ( web:: post ( ) . to ( add_item :: < A > ) ) )
49
+ . service ( web:: resource ( "/update" ) . route ( web:: post ( ) . to ( update_item :: < A > ) ) )
50
+ . service ( web:: resource ( "/delete" ) . route ( web:: post ( ) . to ( delete_item :: < A > ) ) )
51
51
)
52
52
)
53
53
. service (
54
54
web:: scope ( "/contest" )
55
- . service ( web:: resource ( "/create" ) . route ( web:: post ( ) . to ( create_contest) ) )
56
- . service ( web:: resource ( "/update" ) . route ( web:: post ( ) . to ( update_contest) ) )
57
- . service ( web:: resource ( "/item/update" ) . route ( web:: post ( ) . to ( update_items) ) )
58
- . service ( web:: resource ( "/get/{contest_id}" ) . route ( web:: get ( ) . to ( get_single_contest) ) )
59
- . service ( web:: resource ( "/join" ) . route ( web:: post ( ) . to ( join_contest) ) )
60
- . service ( web:: resource ( "/leave" ) . route ( web:: post ( ) . to ( leave_contest) ) )
61
- . service ( web:: resource ( "/my" ) . route ( web:: get ( ) . to ( get_my_contests) ) )
62
- . service ( web:: resource ( "/joined" ) . route ( web:: get ( ) . to ( get_participated) ) )
63
- . service ( web:: resource ( "/recent" ) . route ( web:: get ( ) . to ( get_recent_contests) ) )
55
+ . service ( web:: resource ( "/create" ) . route ( web:: post ( ) . to ( create_contest :: < A > ) ) )
56
+ . service ( web:: resource ( "/update" ) . route ( web:: post ( ) . to ( update_contest :: < A > ) ) )
57
+ . service ( web:: resource ( "/item/update" ) . route ( web:: post ( ) . to ( update_items :: < A > ) ) )
58
+ . service ( web:: resource ( "/get/{contest_id}" ) . route ( web:: get ( ) . to ( get_single_contest :: < A > ) ) )
59
+ . service ( web:: resource ( "/join" ) . route ( web:: post ( ) . to ( join_contest :: < A > ) ) )
60
+ . service ( web:: resource ( "/leave" ) . route ( web:: post ( ) . to ( leave_contest :: < A > ) ) )
61
+ . service ( web:: resource ( "/my" ) . route ( web:: get ( ) . to ( get_my_contests :: < A > ) ) )
62
+ . service ( web:: resource ( "/joined" ) . route ( web:: get ( ) . to ( get_participated :: < A > ) ) )
63
+ . service ( web:: resource ( "/recent" ) . route ( web:: get ( ) . to ( get_recent_contests :: < A > ) ) )
64
64
)
65
65
. service (
66
66
web:: scope ( "/user" )
67
- . service ( web:: resource ( "/get" ) . route ( web:: get ( ) . to ( internal_user:: get) ) )
68
- . service ( web:: resource ( "/update" ) . route ( web:: post ( ) . to ( internal_user:: update) ) )
67
+ . service ( web:: resource ( "/get" ) . route ( web:: get ( ) . to ( internal_user:: get :: < A > ) ) )
68
+ . service ( web:: resource ( "/update" ) . route ( web:: post ( ) . to ( internal_user:: update :: < A > ) ) )
69
69
)
70
70
. service (
71
71
web:: scope ( "/progress_reset" )
72
- . service ( web:: resource ( "/list" ) . route ( web:: get ( ) . to ( get_progress_reset_list) ) )
73
- . service ( web:: resource ( "/add" ) . route ( web:: post ( ) . to ( add_progress_reset_item) ) )
74
- . service ( web:: resource ( "/delete" ) . route ( web:: post ( ) . to ( delete_progress_reset_item) ) )
72
+ . service ( web:: resource ( "/list" ) . route ( web:: get ( ) . to ( get_progress_reset_list :: < A > ) ) )
73
+ . service ( web:: resource ( "/add" ) . route ( web:: post ( ) . to ( add_progress_reset_item :: < A > ) ) )
74
+ . service ( web:: resource ( "/delete" ) . route ( web:: post ( ) . to ( delete_progress_reset_item :: < A > ) ) )
75
75
)
76
76
) . service (
77
77
web:: scope ( "/atcoder-api" )
78
- . service ( web:: resource ( "/results" ) . route ( web:: get ( ) . to ( get_user_submissions) ) )
78
+ . service ( web:: resource ( "/results" ) . route ( web:: get ( ) . to ( get_user_submissions :: < A > ) ) )
79
79
. service (
80
80
web:: scope ( "/v2" )
81
- . service ( web:: resource ( "/user_info" ) . route ( web:: get ( ) . to ( get_user_info) ) )
81
+ . service ( web:: resource ( "/user_info" ) . route ( web:: get ( ) . to ( get_user_info :: < A > ) ) )
82
82
)
83
83
. service (
84
84
web:: scope ( "/v3" )
85
- . service ( web:: resource ( "/user_info" ) . route ( web:: get ( ) . to ( get_user_info) ) )
86
- . service ( web:: resource ( "/rated_point_sum_ranking" ) . route ( web:: get ( ) . to ( get_rated_point_sum_ranking) ) )
87
- . service ( web:: resource ( "/ac_ranking" ) . route ( web:: get ( ) . to ( ranking :: ranking ( get_ac_ranking ) ) ) )
88
- . service ( web:: resource ( "/streak_ranking" ) . route ( web:: get ( ) . to ( ranking :: ranking ( get_streak_ranking ) ) ) )
89
- . service ( web:: resource ( "/language_ranking" ) . route ( web:: get ( ) . to ( get_language_ranking) ) )
90
- . service ( web:: resource ( "/from/{from}" ) . route ( web:: get ( ) . to ( get_time_submissions) ) )
91
- . service ( web:: resource ( "/recent" ) . route ( web:: get ( ) . to ( get_recent_submissions) ) )
92
- . service ( web:: resource ( "/users_and_time" ) . route ( web:: get ( ) . to ( get_users_time_submissions) ) )
85
+ . service ( web:: resource ( "/user_info" ) . route ( web:: get ( ) . to ( get_user_info :: < A > ) ) )
86
+ . service ( web:: resource ( "/rated_point_sum_ranking" ) . route ( web:: get ( ) . to ( get_rated_point_sum_ranking :: < A > ) ) )
87
+ . service ( web:: resource ( "/ac_ranking" ) . route ( web:: get ( ) . to ( < AcRanking as RankingSelector < A > > :: get_ranking ) ) )
88
+ . service ( web:: resource ( "/streak_ranking" ) . route ( web:: get ( ) . to ( < StreakRanking as RankingSelector < A > > :: get_ranking ) ) )
89
+ . service ( web:: resource ( "/language_ranking" ) . route ( web:: get ( ) . to ( get_language_ranking :: < A > ) ) )
90
+ . service ( web:: resource ( "/from/{from}" ) . route ( web:: get ( ) . to ( get_time_submissions :: < A > ) ) )
91
+ . service ( web:: resource ( "/recent" ) . route ( web:: get ( ) . to ( get_recent_submissions :: < A > ) ) )
92
+ . service ( web:: resource ( "/users_and_time" ) . route ( web:: get ( ) . to ( get_users_time_submissions :: < A > ) ) )
93
93
. service (
94
94
web:: scope ( "/user" )
95
- . service ( web:: resource ( "/submissions" ) . route ( web:: get ( ) . to ( get_user_submissions_from_time) ) )
96
- . service ( web:: resource ( "/submission_count" ) . route ( web:: get ( ) . to ( get_user_submission_count) ) )
97
- . service ( web:: resource ( "/ac_rank" ) . route ( web:: get ( ) . to ( ranking :: user_rank ( get_users_ac_rank ) ) ) )
98
- . service ( web:: resource ( "/streak_rank" ) . route ( web:: get ( ) . to ( ranking :: user_rank ( get_users_streak_rank ) ) ) )
99
- . service ( web:: resource ( "/language_rank" ) . route ( web:: get ( ) . to ( get_users_language_rank) ) )
100
- . service ( web:: resource ( "rated_point_sum_rank" ) . route ( web:: get ( ) . to ( ranking :: user_rank ( get_users_rated_point_sum_rank ) ) ) )
95
+ . service ( web:: resource ( "/submissions" ) . route ( web:: get ( ) . to ( get_user_submissions_from_time :: < A > ) ) )
96
+ . service ( web:: resource ( "/submission_count" ) . route ( web:: get ( ) . to ( get_user_submission_count :: < A > ) ) )
97
+ . service ( web:: resource ( "/ac_rank" ) . route ( web:: get ( ) . to ( < AcRanking as UserRankSelector < A > > :: get_users_rank ) ) )
98
+ . service ( web:: resource ( "/streak_rank" ) . route ( web:: get ( ) . to ( < StreakRanking as UserRankSelector < A > > :: get_users_rank ) ) )
99
+ . service ( web:: resource ( "/language_rank" ) . route ( web:: get ( ) . to ( get_users_language_rank :: < A > ) ) )
100
+ . service ( web:: resource ( "rated_point_sum_rank" ) . route ( web:: get ( ) . to ( < RatedPointSumRanking as UserRankSelector < A > > :: get_users_rank ) ) )
101
101
)
102
- . service ( web:: resource ( "language_list" ) . route ( web:: get ( ) . to ( get_language_list) ) )
102
+ . service ( web:: resource ( "language_list" ) . route ( web:: get ( ) . to ( get_language_list :: < A > ) ) )
103
103
)
104
104
)
105
- . service ( web:: resource ( "/healthcheck" ) . route ( web:: get ( ) . to ( |_| async move { Ok ( "" ) } ) ) ) ;
105
+ . service ( web:: resource ( "/healthcheck" ) . route ( web:: get ( ) . to ( || HttpResponse :: Ok ( ) . finish ( ) ) ) ) ;
106
106
}
0 commit comments