更新http服务器 剔除反射功能

This commit is contained in:
2025-03-31 15:08:04 +08:00
parent 5acd63eb99
commit 34d37e579b
9 changed files with 233 additions and 109 deletions

View File

@@ -1,4 +1,3 @@
import 'dart:io';
abstract class WebServer {
static late WebServer _webServer;
@@ -11,7 +10,7 @@ abstract class WebServer {
_webServer = server;
}
void start(int port);
void start(int port, {Function? interceptor});
void stop();
void addHandler(handler);
}
@@ -24,6 +23,14 @@ enum HttpMethod {
ALL,
WS,
;
static HttpMethod valueOf(String type) {
var tmp = HttpMethod.values.where((t) => t.name == type).toList();
if (tmp.isEmpty) {
return HttpMethod.ALL;
}
return tmp[0];
}
}
enum HttpResponseType {
@@ -37,6 +44,14 @@ enum HttpResponseType {
final String type;
const HttpResponseType(this.type);
static HttpResponseType valueOf(String type) {
var tmp = HttpResponseType.values.where((t) => t.type == type).toList();
if (tmp.isEmpty) {
return HttpResponseType.JSON;
}
return tmp[0];
}
}
class RequestMapping {