Skip to content
This repository was archived by the owner on Dec 3, 2020. It is now read-only.

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://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

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages