Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.
/ ExpressSharp Public archive

Performant C# framework for Express-like web API's

Notifications You must be signed in to change notification settings

TatoExp/ExpressSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Development has been moved to here

🌐 ExpressSharp

👷 Installation

Get it from Nuget

Latest

Download from releases

Latest

🕴️ Usage

GET

The code below shows how to initialise an Express server, how to set up a callback to a path and how to send data back to the user.

using ExpressSharp;
...
Express server = new Express();

server.GET("/helloworld", (req, res) =>
{
  res.Send("Hello, world!");
});

server.Listen(80);

If you visit your browser at http:https://localhost/helloworld it should display "Hello, world!", this means that it is working successfully.

POST

TODO

Middleware

Middleware is code that is executed before your callback is executed, for example I will have a middleware which will just write "Im middleware" to the console when the user accesses a page, however, this can be used for other things such as authentication headers, to avoid repeating code within each callback.

using ExpressSharp;
...
Express server = new Express();

server.Use((req, res, next) =>
{
  Console.WriteLine("Im middleware");
  next();
});

server.GET("/helloworld", (req, res) =>
{
  res.Send("Hello, world!");
});

server.Listen(80);

In this example you may notice the usage of next(), calling this function calls either the next middleware or the callback depending on whether it is the last middleware to be called, middleware is only called if the path exists as a binding.

🥅 Goals

  • Usable

✨ Contributors


TatoExp

💻

About

Performant C# framework for Express-like web API's

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages