A basic HTTP server framework written in C#.
GNU GPL, "giving you legal permission to copy, distribute and/or modify it."
I'm not actively developing this project at present, but I want to revive it. It is being used in an academic setting. If I can add any functionality to assist your project, feel free to get in touch. Alternatively, I'm open to pull requests.
using JamesWright.SimpleHttp;
using System.Threading;
using System.Threading.Tasks;
namespace JamesWright.SimpleHttp.Example
{
class Program
{
static void Main(string[] args)
{
App app = new App();
app.Get("/", async (req, res) =>
{
res.Content = "<p>You did a GET.</p>";
res.ContentType = "text/html";
await res.SendAsync();
});
app.Post("/", async (req, res) =>
{
res.Content = "<p>You did a POST: " + await req.GetBodyAsync() + "</p>";
res.ContentType = "text/html";
await res.SendAsync();
});
app.Put("/", async (req, res) =>
{
res.Content = "<p>You did a PUT: " + await req.GetBodyAsync() + "</p>";
res.ContentType = "text/html";
await res.SendAsync();
});
app.Delete("/", async (req, res) =>
{
res.Content = "<p>You did a DELETE: " + await req.GetBodyAsync() + "</p>";
res.ContentType = "text/html";
await res.SendAsync();
});
app.Start();
}
}
}
Represents an application, served over HTTP, and the requests for which it will listen.
Adds a handler for a HTTP GET request to the requested endpoint.
Adds a handler for a HTTP POST request to the requested endpoint.
Adds a handler for a HTTP PUT request to the requested endpoint.
Adds a handler for a HTTP DELETE request to the requested endpoint.
Initialises the server and its underlying listener. Port number can be optionally specified.
A HTTP request, and its underlying information, that is sent to the server.
Returns the endpoint that the Request instance represents e.g. "/".
Contains the parameters sent with the HTTP request. Currently not populated.
Returns the request's body asynchronously.
A response to be sent to the user.
The body content to be returned to the user.
The Internet media type (MIME) of the response e.g. "application/json".
Sends the response asynchronously.
- Request parameters
- JSON
- NuGet
- HTTPS/SSL
- Memory management
- Unit tests