minimal-apis.github.io icon indicating copy to clipboard operation
minimal-apis.github.io copied to clipboard

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

Open davidfowl opened this issue 2 years ago • 7 comments

What would you like see:

  • [x] 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();

davidfowl avatar Aug 29 '21 13:08 davidfowl

Isn't this already covered in the current quick start https://minimal-apis.github.io/quickstart/quickstart.html

LadyNaggaga avatar Aug 30 '21 18:08 LadyNaggaga

There's no plan to cover other frameworks in that set. This is about having a "if you know framework X" here's how you do it in minimal comparison

davidfowl avatar Aug 30 '21 19:08 davidfowl

What about something like this on the homepage under features? I don't know if we should do entire section. TBH I don't know where this would be go in the page flow

image

LadyNaggaga avatar Aug 30 '21 19:08 LadyNaggaga

Maybe I could add an about page ...

LadyNaggaga avatar Aug 30 '21 19:08 LadyNaggaga

I think it should be a different page. One per framework. One for express and one for flask, and maybe a golang framework.

davidfowl avatar Aug 30 '21 19:08 davidfowl

😑 I am not sure about this. But we could add a section under the quick starts. But it may get lost. Right now this what we have Top menus

  • Quick starts
  • Tutorials
  • Samples
  • MS Docs

LadyNaggaga avatar Aug 30 '21 20:08 LadyNaggaga

Example https://hapi.dev/tutorials/expresstohapi/?lang=en_US

davidfowl avatar Sep 06 '21 16:09 davidfowl