89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
using System;
|
|
|
|
namespace EonaCat.Network
|
|
{
|
|
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
|
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
|
|
|
/// <summary>
|
|
/// Default pages served by the EonaCat webserver.
|
|
/// </summary>
|
|
public class EonaCatWebserverPages
|
|
{
|
|
/// <summary>
|
|
/// Page displayed when sending a 404 due to a lack of a route.
|
|
/// </summary>
|
|
public Page Default404Page
|
|
{
|
|
get
|
|
{
|
|
return _Default404Page;
|
|
}
|
|
set
|
|
{
|
|
if (value == null)
|
|
throw new ArgumentNullException(nameof(Default404Page));
|
|
_Default404Page = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Page displayed when sending a 500 due to an exception is unhandled within your routes.
|
|
/// </summary>
|
|
public Page Default500Page
|
|
{
|
|
get
|
|
{
|
|
return _Default500Page;
|
|
}
|
|
set
|
|
{
|
|
if (value == null)
|
|
throw new ArgumentNullException(nameof(Default500Page));
|
|
_Default500Page = value;
|
|
}
|
|
}
|
|
|
|
private Page _Default404Page = new Page("text/plain", "Not found");
|
|
private Page _Default500Page = new Page("text/plain", "Internal server error");
|
|
|
|
/// <summary>
|
|
/// Default pages served by the EonaCat webserver.
|
|
/// </summary>
|
|
public EonaCatWebserverPages()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Page served by the EonaCat webserver.
|
|
/// </summary>
|
|
public class Page
|
|
{
|
|
/// <summary>
|
|
/// Content type.
|
|
/// </summary>
|
|
public string ContentType { get; private set; } = null;
|
|
|
|
/// <summary>
|
|
/// Content.
|
|
/// </summary>
|
|
public string Content { get; private set; } = null;
|
|
|
|
/// <summary>
|
|
/// Page served by the EonaCat webserver.
|
|
/// </summary>
|
|
/// <param name="contentType">Content type.</param>
|
|
/// <param name="content">Content.</param>
|
|
public Page(string contentType, string content)
|
|
{
|
|
if (String.IsNullOrEmpty(contentType))
|
|
throw new ArgumentNullException(nameof(contentType));
|
|
if (String.IsNullOrEmpty(content))
|
|
throw new ArgumentNullException(nameof(content));
|
|
|
|
ContentType = contentType;
|
|
Content = content;
|
|
}
|
|
}
|
|
}
|
|
} |