Phema.Routing 3.0.1

C# typed routing library for ASP.NET Core

There is a newer version of this package available.
See the version list below for details.
Install-Package Phema.Routing -Version 3.0.1
dotnet add package Phema.Routing --version 3.0.1
<PackageReference Include="Phema.Routing" Version="3.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Phema.Routing --version 3.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Phema.Routing, 3.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Phema.Routing as a Cake Addin
#addin nuget:?package=Phema.Routing&version=3.0.1

// Install Phema.Routing as a Cake Tool
#tool nuget:?package=Phema.Routing&version=3.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Phema.Routing

Build Status Nuget

C# strongly typed routing library for ASP.NET Core built on top of MVC Model conventions with built-in From.*, ApiExplorer, Authorization and Caching support

Features

  • Flexible constraint and filter configuration
  • Extension methods for authorization, caching, api documentation
  • Selection BindingSources and named parameters (constant names only) e.g. From.Body, From.Form, From.Route etc.
  • Parameter name override e.g. From.Query<int>("id_override") /route?id_override=12345
  • Extensions
    • Http methods - .HttpPost()...
    • Caching - .Cached(...)
    • Authorization - .Authorize(...), .AllowAnonymous()
    • AntiForgeryToken - .ValidateAntiForgeryToken(), .IgnoreAntiforgeryToken()
    • Https - .RequireHttps()
    • RequestSizeLimit - .RequestSizeLimit(...), .DisableRequestSizeLimit()
    • Produce, Consume for ApiExplorer - .Produces<TModel>(...), .Consumes(...)

Usage

// Startup
services.AddMvcCore() // .AddMvc()
  .AddRouting(routing =>
  {
    // Simple route
    routing.AddController<OrdersController>("orders", controller =>
      controller.AddRoute("dashboard", c => c.Dashboard())
        .HttpGet());

    // Authorize controller with "id" parameter from query
    routing.AddController<TaskController>("tasks", controller =>
      controller.AddRoute("edit", c => c.Edit(From.Query<int>("id"))) // `From.*` is matches `[From*]` attributes
        .HttpGet()
        .Authorize());

    // Multiple routes in one controller
    routing.AddController<WashingController>("washing", controller =>
    {
      // Override controller .Authorize()
      controller.AddRoute("wash", c => c.Wash(From.Query<int>())) // If name not specified - used method parameter name
        .HttpGet()
        .AllowAnonymous()

      // Inherit authorization requirement from controller
      controller.AddRoute("dry", c => c.Dry(From.Body<DryModel>()))
        .HttpPost()
        .ValidateAntiForgeryToken();

    }).Authorize()
  });

Phema.Routing

Build Status Nuget

C# strongly typed routing library for ASP.NET Core built on top of MVC Model conventions with built-in From.*, ApiExplorer, Authorization and Caching support

Features

  • Flexible constraint and filter configuration
  • Extension methods for authorization, caching, api documentation
  • Selection BindingSources and named parameters (constant names only) e.g. From.Body, From.Form, From.Route etc.
  • Parameter name override e.g. From.Query<int>("id_override") /route?id_override=12345
  • Extensions
    • Http methods - .HttpPost()...
    • Caching - .Cached(...)
    • Authorization - .Authorize(...), .AllowAnonymous()
    • AntiForgeryToken - .ValidateAntiForgeryToken(), .IgnoreAntiforgeryToken()
    • Https - .RequireHttps()
    • RequestSizeLimit - .RequestSizeLimit(...), .DisableRequestSizeLimit()
    • Produce, Consume for ApiExplorer - .Produces<TModel>(...), .Consumes(...)

Usage

// Startup
services.AddMvcCore() // .AddMvc()
  .AddRouting(routing =>
  {
    // Simple route
    routing.AddController<OrdersController>("orders", controller =>
      controller.AddRoute("dashboard", c => c.Dashboard())
        .HttpGet());

    // Authorize controller with "id" parameter from query
    routing.AddController<TaskController>("tasks", controller =>
      controller.AddRoute("edit", c => c.Edit(From.Query<int>("id"))) // `From.*` is matches `[From*]` attributes
        .HttpGet()
        .Authorize());

    // Multiple routes in one controller
    routing.AddController<WashingController>("washing", controller =>
    {
      // Override controller .Authorize()
      controller.AddRoute("wash", c => c.Wash(From.Query<int>())) // If name not specified - used method parameter name
        .HttpGet()
        .AllowAnonymous()

      // Inherit authorization requirement from controller
      controller.AddRoute("dry", c => c.Dry(From.Body<DryModel>()))
        .HttpPost()
        .ValidateAntiForgeryToken();

    }).Authorize()
  });

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.0.5 314 9/25/2019
3.0.4 240 8/27/2019
3.0.3 250 7/27/2019
3.0.2 224 7/26/2019
3.0.1 240 7/25/2019
3.0.0 227 7/19/2019