1
0
Fork 0
mirror of https://gitlab.com/sbrl/GalleryShare.git synced 2018-06-12 22:45:16 +00:00
GalleryShare/GalleryShare/RequestRouter/RouteDefault.cs
Starbeamrainbowlabs 60b7560d21 Initial routing rewrite.
The routes aren't functioning correctly yet.
2016-07-16 15:46:53 +01:00

40 lines
927 B
C#

using System;
using GalleryShare.RequestRouter;
using System.Threading.Tasks;
using System.Net;
using System.IO;
namespace GalleryShare
{
public class RouteDefault : IRequestRoute
{
public int Priority { get; } = 0;
public string DefaultResponse { get; set; } = "Error: 404 - No route was found to handle the specified url.\n";
public RouteDefault()
{
}
public bool CanHandle(string rawUrl, string requestedPath)
{
return true;
}
public void SetParentServer(GalleryServer inParentServer)
{
}
public async Task HandleRequestAsync(HttpListenerContext cycle, string requestedPath)
{
cycle.Response.StatusCode = 404;
cycle.Response.ContentType = "text/plain";
cycle.Response.ContentLength64 = DefaultResponse.Length;
StreamWriter responseData = new StreamWriter(cycle.Response.OutputStream) { AutoFlush = true };
await responseData.WriteLineAsync(DefaultResponse);
}
}
}