Skip to content

Add a section that shows how concepts in other frameworks apply using minimal APIs #47

Description

@davidfowl

What would you like see:

  • Documentation
  • Sample
  • Tutorial

What kind of content are you looking for ?

We should have a section on the site that lists a couple of top level concepts in various frameworks (routing, middleware, logging, dependency injection (where applicable)), as a way to quickly get somebody that is already using an existing framework up to speed with similar concepts in minimal.

For example:

Express

Routes

// GET method route
app.get('/', function (req, res) {
  res.send('GET request to the homepage')
})

// POST method route
app.post('/', function (req, res) {
  res.send('POST request to the homepage')
})
app.MapGet("/", () => "GET request to the homepage");
app.MapPost("/", () => "POST request to the homepage");

Route parameters

app.get('/users/:userId/books/:bookId', function (req, res) {
  res.send(req.params)
})
app.MapGet("/users/{userId}/books/{bookId}", (int userId, int bookId) => { 
   return new { userId, bookId };
});

Middleware

var express = require('express')
var app = express()

app.use(function (req, res, next) {
  console.log('Time:', Date.now())
  next()
})
var app = WebApplication.Create(args);

app.Use((context, next) => 
{
    Console.WriteLine($"Time: {DateTime.Now}");
    return next(context);
});

StaticFiles

var express = require('express')
var app = express()

app.use(express.static('public', options))
var app = WebApplication.Create(args);
app.UseStaticFiles();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions