question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Convention based route builder

See original GitHub issue

I have another suggestion - which I can help you implement.

The idea would be to have an option to activate a convention based route builder. This means that you don’t have to specify your route if you want it to follow the namespace in which you are working.

From your same Web application:

namespace Customers.List.Recent;
public class Endpoint : EndpointWithoutRequest
{
    public override void Configure()
    {
        Verbs(Http.GET);
        Routes("/customer/list/recent");
    }
}

So basically the Routes can be build automatically using the namespace.

You would still be able to set (additional) routes manually if you choose for this convention based option.

In this option you can add “ignore” words (for example, if your namespace would contain MyCompany.Features.Customers.List.Recent you could add “MyCompany” and “Features” as ignore words). Furthermore you could decide on formatting: lower-case, pascal-wording, etc. Inventory.GetProduct -> inventory/get-product for example.

Again, this would be totally optional as all the rest and I don’t think it would affect performance when building the routes.

What do you think? Would it be an idea to add (I can make a PR if you want). If you don’t like it, or think the lib we be “too much” just say 😃

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
stefandevocommented, Jan 19, 2022

Okay understood! No problem. I can easily add it for my own project in base classes. So I am good.

0reactions
dj-nitehawkcommented, Jan 20, 2022

good stuff 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core Convention based Routing
ASP.NET Core Convention based routing is based on set of conventions of URL Patterns. We configure these conventions in UseEndpoints method.
Read more >
Routing to controller actions in ASP.NET Core
It's called conventional routing because it establishes a convention for URL paths: The first path segment, {controller=Home} , maps to the ...
Read more >
Routing in ASP.NET Core
Conventional routing: The route is determined based on conventions that are defined in route templates that, at runtime, will map requests ...
Read more >
Routing in ASP.NET Core
Discover how ASP.NET Core routing is responsible for matching HTTP requests and dispatching to executable endpoints.
Read more >
Learn ASP.NET Core Convention-Based Routing
Generates URLs for the links based on the defined routes. ... Convention-Based Routing (this tutorial) – Routes are applied on the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found