更新web服务器自定义token解析回调

This commit is contained in:
2025-04-18 11:06:34 +08:00
parent 700479d131
commit cff5448fe0
6 changed files with 91 additions and 25 deletions

View File

@@ -1,4 +1,3 @@
abstract class WebServer {
static late WebServer _webServer;
@@ -10,7 +9,8 @@ abstract class WebServer {
_webServer = server;
}
void start(int port, {Function? interceptor});
void start(int port,
{Function? interceptor, TokenResult Function(String?)? tokenCheck});
void stop();
void addHandler(handler);
}
@@ -58,9 +58,18 @@ class RequestMapping {
final HttpMethod method;
final String path;
final HttpResponseType responseType;
final bool auth;
const RequestMapping(
{this.method = HttpMethod.ALL,
required this.path,
this.auth = true,
this.responseType = HttpResponseType.JSON});
}
class TokenResult {
bool status;
String? errMsg;
Map<String, dynamic>? payload;
TokenResult({required this.status, this.errMsg, this.payload});
}