mirror of
https://gitlab.com/sbrl/GalleryShare.git
synced 2018-06-12 22:45:16 +00:00
Add error handling to root HttpListener handler
This commit is contained in:
parent
60b7560d21
commit
2d020ab168
2 changed files with 19 additions and 6 deletions
|
@ -4,7 +4,6 @@ using System.Threading.Tasks;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.Threading;
|
||||
using System.Xml;
|
||||
using System.Reflection;
|
||||
|
@ -78,10 +77,24 @@ namespace GalleryShare
|
|||
/// <param name="cycle">The Http request to handle.</param>
|
||||
private async Task Handle(HttpListenerContext cycle)
|
||||
{
|
||||
await router.RouteRequest(cycle);
|
||||
|
||||
logCycle(cycle);
|
||||
cycle.Response.Close();
|
||||
try
|
||||
{
|
||||
await router.RouteRequest(cycle);
|
||||
logCycle(cycle);
|
||||
}
|
||||
catch(Exception error)
|
||||
{
|
||||
Console.WriteLine("[{0}] [{1}] [Error] {2} ({3})",
|
||||
DateTime.Now.ToString("hh:m tt"),
|
||||
cycle.Request.RemoteEndPoint,
|
||||
cycle.Request.RawUrl,
|
||||
error.Message
|
||||
);
|
||||
}
|
||||
finally
|
||||
{
|
||||
cycle.Response.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private string GetFullReqestedPath(string rawUrl)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace GalleryShare.RequestRouter
|
|||
|
||||
public class MasterHttpRouter
|
||||
{
|
||||
public bool DebugMode = true;
|
||||
public bool DebugMode = false;
|
||||
|
||||
List<IRequestRoute> requestRoutes = new List<IRequestRoute>();
|
||||
UrlPathTransformer urlTransformer;
|
||||
|
|
Loading…
Reference in a new issue