1
1
//! `struct RequestParser`の定義
2
2
3
3
use std:: str:: from_utf8;
4
+ use std:: sync:: Arc ;
4
5
5
6
use crate :: error:: { Error , ErrorKind , Result } ;
6
7
use crate :: macros:: all_events;
@@ -37,6 +38,19 @@ fn valid_header_value(value: &str) -> bool {
37
38
. all ( |c| ( 0x20 ..=0x7E ) . contains ( c) || * c == 0x09 )
38
39
}
39
40
41
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
42
+ pub ( crate ) struct Inner {
43
+ verification_token : String ,
44
+ }
45
+
46
+ impl Inner {
47
+ pub ( crate ) fn new ( verification_token : & str ) -> Self {
48
+ Self {
49
+ verification_token : verification_token. to_string ( ) ,
50
+ }
51
+ }
52
+ }
53
+
40
54
impl RequestParser {
41
55
/// 新しい`RequestParser`を作成します。
42
56
///
@@ -50,7 +64,7 @@ impl RequestParser {
50
64
/// ```
51
65
pub fn new ( verification_token : & str ) -> Self {
52
66
Self {
53
- verification_token : verification_token . to_string ( ) ,
67
+ inner : Arc :: new ( Inner :: new ( verification_token ) ) ,
54
68
}
55
69
}
56
70
@@ -142,7 +156,7 @@ impl RequestParser {
142
156
. then_some ( t)
143
157
. ok_or ( ErrorKind :: ReadBotTokenFailed )
144
158
} )
145
- . map ( |t| t == self . verification_token ) ?
159
+ . map ( |t| t == self . inner . verification_token ) ?
146
160
. then_some ( ( ) )
147
161
. ok_or ( ErrorKind :: BotTokenMismatch ) ?;
148
162
kind. ok_or ( ErrorKind :: BotEventNotFound )
0 commit comments