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.

Route order in fastendpoints library

See original GitHub issue

How can I fix the route order in fastendpoints library? I have two routes: /onboarding/{OnboardingId} and /onboarding/restore. But fastendpoints always goes to the first route because it thinks restore is also an OnboardingId.

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dj-nitehawkcommented, Jun 9, 2023

just tried the following and it works as expected:

public class RestoreRequest
{
    [QueryParam]
    public string CrmId { get; set; }
}

public class RestoreEndpoint : Endpoint<RestoreRequest>
{
    public override void Configure()
    {
        Get("/onboarding/restore");
        AllowAnonymous();
    }

    public override async Task HandleAsync(RestoreRequest r, CancellationToken c)
    {
        await SendAsync($"Hi from /onboarding/restore?crmId={r.CrmId}");
    }
}

public class OnboardingEndpoint : EndpointWithoutRequest
{
    public override void Configure()
    {
        Get("/onboarding/{onboardingId:minlength(10)}");
        AllowAnonymous();
    }

    public override async Task HandleAsync(CancellationToken c)
    {
        await SendAsync($"Hi from /onboarding/{Route<string>("onboardingId")}");
    }
}
0reactions
itsoli91commented, Jun 6, 2023

This is interesting…  if I put the restore method on top of another method http://localhost:5019/onboarding/restore now returns 200 ok

app.MapGet("/onboarding/restore",
        ([FromQuery] string? crmId) =>
        {
            return $"Hi from /onboarding/restore?crmId={crmId}";
        })
    .WithOpenApi();

app.MapGet("/onboarding/{onboardingId:minlength(10)}",
        (string onboardingId) =>
        {
            return $"Hi from /onboarding/{onboardingId}";
        })
    .WithOpenApi();
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration Settings
A light-weight REST Api framework for ASP.Net 6 that implements REPR (Request-Endpoint-Response) Pattern.
Read more >
Advantages and disadvantages of FastEndpoints : r/dotnet
I'm really curious, what's the gain (except performance) compared to a single-action vanilla controller organized in the same fashion? [Route("/ ...
Read more >
How to read claim values + handling multiple http verbs #8
Hi, i'm so happy to see your fastendpoints and started to use it, and still not reach at there where i can find...
Read more >
Building REST APIs In .Net 6 The Easy Way!
we will be exploring the open source endpoint library FastEndpoints which is built on top of the new minimal api in .net 6,...
Read more >
Routing in ASP.NET Core
Routing is responsible for matching incoming HTTP requests and dispatching those requests to the app's executable endpoints.
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