handleRequest method
Implementation
handleRequest(HttpRequest request) async {
try{
final x = endpoints.keys.firstWhere((element) => element.hasMatch(request.requestedUri.path));
await endpoints[x]!.handleRequest(request,URIHandler.parsePath(endpoints[x]!.urlpattern,request.requestedUri.path));
print("${_host.address} - - [${ServerUtils.printDateTime()}] '${request.method} ${request.uri.path} HTTP/${request.protocolVersion}' 200");
}on HttpException catch(e){
print("${_host.address} - - [${ServerUtils.printDateTime()}] '${request.method} ${request.uri.path} HTTP/${request.protocolVersion}' 500");
await request.response
..statusCode = 500
..headers.contentType = ContentType.json
..write(jsonEncode({'message':e.message}))
..close();
return;
}on StateError {
request.response
..statusCode = 500
..headers.contentType = ContentType.json
..write(jsonEncode({'message':"No endpoint named ${request.requestedUri.path}"}))
..close();
}
}