unosquare / embedio

A tiny, cross-platform, module based web server for .NET
http://unosquare.github.io/embedio
Other
1.46k stars 176 forks source link

Case-insensitive routing #521

Open gabriele-ricci-kyklos opened 3 years ago

gabriele-ricci-kyklos commented 3 years ago

Given an example GET method

[Route(HttpVerbs.Get, "/GetTest/{id?}")]
public string GetTest(int? id)
{
    return $"GetTest success [id={id}]!";
}

I realized that routing is case sensitive. If I visit http://localhost:1234/api/gettest/1 I get a 404 error, while it works by visiting http://localhost:1234/api/GetTest/1.

I didn't find any option in the docs, is there a way to make it insensitive match?

rdeago commented 3 years ago

Case sensitivity was a design decision I made two years ago, for the reasons explained in https://github.com/unosquare/embedio/issues/282#issuecomment-490919846.

This does not mean that it was the right choice, ot that it cannot be changed. However, case insensitivity should be introduced on a module-by-module basis and with great care, because of a bunch of possible compatibility issues and the number of corner cases involved.

I'm leaving this issue open, so anyone interested may leave comment and suggestions, but for now the answer is no: routing in EmbedIO is case-sensitive by design, with no option to make it case-insensitive.

captainjono commented 3 years ago

Im trying to use EmbedIO cross platform (ff,.net5, xam - the whole hog) and i just hit this being a blocker - so im having to fork :| Im also having to fork so i can set MineTypes.Default = "what i want".

Yeh, my apps may not be standards compliant - but who's code-base is? I understand perf considerations given the above and case sensitive may be a sensible default.

BUT I think EmbedIO really need to think about what is is - in my book its a flexible self-hosted web server... Give me flexibility please! I dont want to fork for 2 lines of code which should be simple server config. Ie let me inject my own mime provider atleast! At Also let me inject things like a pre-request handler which i can implement case-insensitivty on request URLS... (PRs accepted?)