neuecc / LightNode

Micro RPC/REST Framework built on OWIN
http://neuecc.github.io/LightNode
MIT License
181 stars 32 forks source link

Resolve for long slashed path #26

Closed neuecc closed 10 years ago

neuecc commented 10 years ago

host api/v1/a/b api/v2/a/b ... remove api/vs

neuecc commented 10 years ago

should use other middleware. for example

// Conditional Use
app.MapWhen(x => x.Request.Path.Value.StartsWith("/v1/"), ap =>
{
});

app.MapWhen(x => x.Request.Path.Value.StartsWith("/v2/"), ap =>
{
});

// Trim Version Path
app.Use((context, next) =>
{
    context.Request.Path = new Microsoft.Owin.PathString(
        Regex.Replace(context.Request.Path.Value, @"^/v[1-9]/", "/"));
    return next();
});