更新http服务器 剔除反射功能
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user