|
@@ -24,6 +24,7 @@ namespace MiniWebApi.Network
|
|
|
|
|
|
public WebApiRouter(string applicationName, Assembly assembly)
|
|
|
{
|
|
|
+ File.AppendAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"ApiLog.txt"),$"Register Start {assembly.FullName}\n");
|
|
|
_assembly = assembly;
|
|
|
_applicationName = applicationName;
|
|
|
_applicationName = _applicationName == null ? string.Empty : _applicationName.ToLower();
|
|
@@ -67,10 +68,12 @@ namespace MiniWebApi.Network
|
|
|
{
|
|
|
_assembly = Assembly.GetEntryAssembly();
|
|
|
}
|
|
|
- var handlerTypes = _assembly. GetTypes().Where(x =>
|
|
|
- typeof(BaseHandler).IsAssignableFrom(x) && x != typeof(BaseHandler)).ToArray();
|
|
|
+ File.AppendAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"ApiLog.txt"),$"RegisterHandlers Start {_assembly.FullName}\n");
|
|
|
+ var handlerTypes = _assembly.GetTypes().Where(x =>
|
|
|
+ x.IsSubclassOf(typeof(BaseHandler)) && x != typeof(BaseHandler)).ToArray();
|
|
|
foreach (var handlerType in handlerTypes)
|
|
|
{
|
|
|
+ File.AppendAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"ApiLog.txt"),$"Register handlerType:{handlerType.Name}\n");
|
|
|
var handlerAttrs = handlerType.GetCustomAttributes(typeof(WebApiHandlerAttribute), false);
|
|
|
if (handlerAttrs.Length > 0)
|
|
|
{
|
|
@@ -81,7 +84,7 @@ namespace MiniWebApi.Network
|
|
|
{
|
|
|
_handlers.Add(key, (BaseHandler)handlerType.New());
|
|
|
}
|
|
|
- //Logger.WriteLineInfo($"Register handler:{key}");
|
|
|
+ File.AppendAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"ApiLog.txt"),$"Register handler:{key}\n");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -178,6 +181,7 @@ namespace MiniWebApi.Network
|
|
|
|
|
|
if (!handlerExist)
|
|
|
{
|
|
|
+ Console.WriteLine($"Handlers {_handlers.Keys}");
|
|
|
Console.WriteLine($"Handler for request: {context.Request.Url} not found.");
|
|
|
context.Response.StatusCode = (int)HttpStatusCode.NotFound;
|
|
|
context.Response.Close();
|