SwiftStack is an opinionated and easy way to build REST APIs, websockets APIs, and RabbitMQ interfaces, taking inspiration from the elegant model shown in FastAPI in Python. Built on Watson webserver.
$ dotnet add package SwiftStackSwiftStack is an opinionated and easy way to build REST APIs taking inspiration from elegant model shown in FastAPI in Python.
If you would like to financially support my efforts, first of all, thank you! Please refer to DONATIONS.md.
using SwiftStack;
SwiftStackApp app = new SwiftStackApp();
// Register a route with no request body
app.Route("GET", "/", async (req) =>
{
return new AppResponse<string>
{
Data = "Hello world",
Result = ApiResultEnum.Success
};
});
// Register a route with a primitive request and response body
app.Route<string, string>("POST", "/loopback", async (req) =>
{
return new AppResponse<string>
{
Data = req.Data,
Result = ApiResultEnum.Success
};
});
// Register a route with a class request and response body
app.Route<User, User>("PUT", "/user/{id}", async (req) =>
{
string id = req.Http.Request.Url.Parameters.Get("id");
return new AppResponse<User>
{
Data = new User { Email = "user" + id + "@bar.com", Password = "password" },
Pretty = true,
Result = ApiResultEnum.Success
};
});
Please refer to CHANGELOG.md for details.
Thanks to pngall.com for making this fantastic logo available.