File tree 1 file changed +8
-1
lines changed
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/adapter/http/plugin
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -13,11 +13,18 @@ import io.ktor.http.*
13
13
import io.ktor.server.application.*
14
14
import io.ktor.server.plugins.*
15
15
import io.ktor.server.request.*
16
+ import io.ktor.util.*
16
17
import net.mamoe.mirai.utils.MiraiLogger
17
18
18
- val logger by lazy { MiraiLogger .Factory .create(HttpRouterMonitor ::class , " MAH Access" ) }
19
+ private val monitor = AttributeKey <Unit >(" HttpRouterMonitor" )
20
+ private val logger by lazy { MiraiLogger .Factory .create(HttpRouterMonitor ::class , " MAH Access" ) }
21
+
19
22
val HttpRouterMonitor = createApplicationPlugin(" HttpRouterAccessMonitor" ) {
20
23
on(Monitor ) { call ->
24
+ if (call.attributes.contains(monitor)) {
25
+ return @on
26
+ }
27
+ call.attributes.put(monitor, Unit )
21
28
call.logAccess()
22
29
}
23
30
}
You can’t perform that action at this time.
0 commit comments