Skip to content

Commit e327519

Browse files
Fix<Request>: RequestAnalyser and request support method log
1 parent 3ef7c29 commit e327519

3 files changed

Lines changed: 66 additions & 3 deletions

File tree

src/main/java/com/talex/talexframe/frame/core/modules/network/connection/RequestAnalyser.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ private void process() {
9090

9191
}
9292

93+
log.info("[解析层] Access in " + methodReceiver.tRequest.value());
94+
9395
if( !clzReceiver.accessChecker( wr ) ) {
9496

95-
return;
97+
continue;
9698

9799
}
98100

@@ -519,10 +521,20 @@ public boolean urlChecker( String comingUrl ) {
519521

520522
}
521523

524+
private String supportMethodName;
525+
522526
/** 返回真则代表方法一致 **/
523527
public boolean methodChecker( String comingMethod ) {
524528

525-
return tReqSupportMethod != null && !ReqMethodUtil.checkStatus(comingMethod, tReqSupportMethod);
529+
return tReqSupportMethod != null && comingMethod.equalsIgnoreCase(this.supportMethodName);
530+
531+
}
532+
533+
public String getSupportMethod() {
534+
535+
this.supportMethodName = ReqMethodUtil.getMethodName(tReqSupportMethod);
536+
537+
return this.supportMethodName;
526538

527539
}
528540

@@ -762,6 +774,8 @@ private void scanClassForRequests(TController controller) {
762774

763775
}
764776

777+
log.debug("[解析层] 扫描到请求: " + request.value() + " #" + requestMethodReceiver.getSupportMethod());
778+
765779
}
766780

767781
this.receivers.put(clz, requestReceiver);

src/main/java/com/talex/talexframe/frame/core/modules/network/connection/RequestConnector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private void headerProcessor() {
9999

100100
if(e.isCancelled()) return;
101101

102-
log.info("[连接层] 请求 " + request.getRequestURI() + " #来自: " + request.getSession().getId() + " 已批准跨域!");
102+
log.info("[连接层] Allowed cors request from " + request.getRemoteAddr() + "(" + request.getRemoteHost() + ")");
103103

104104
wr.returnDataByOK("SUCCESS");
105105

src/main/java/com/talex/talexframe/frame/utils/ReqMethodUtil.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,53 @@ public static boolean checkStatus(String method, TReqSupportMethod reqSupportMet
5757
return false;
5858

5959
}
60+
61+
public static String getMethodName(TReqSupportMethod reqSupportMethod) {
62+
63+
if( reqSupportMethod.get() ) {
64+
65+
return "GET";
66+
67+
}
68+
69+
if( reqSupportMethod.post() ) {
70+
71+
return "POST";
72+
73+
}
74+
75+
if( reqSupportMethod.put() ) {
76+
77+
return "PUT";
78+
79+
}
80+
81+
if( reqSupportMethod.delete() ) {
82+
83+
return "DELETE";
84+
85+
}
86+
87+
if( reqSupportMethod.patch() ) {
88+
89+
return "PATCH";
90+
91+
}
92+
93+
if( reqSupportMethod.head() ) {
94+
95+
return "HEAD";
96+
97+
}
98+
99+
if( reqSupportMethod.options() ) {
100+
101+
return "OPTIONS";
102+
103+
}
104+
105+
return null;
106+
107+
}
108+
60109
}

0 commit comments

Comments
 (0)