Fusion Framework logo by Cipher UnitFusion

Custom HTTP routes

Method-level HTTP routes with [HttpGet] through [HttpOptions] in C#

Convention vs custom

ModeHowMount path
ConventionMethods named Get, Post, Put, Patch, Delete, Head, Options (case-insensitive)Class base path from [Route]
Custom[HttpGet] … [HttpOptions] on any methodBase path joined with the template

Both can live on the same class.

Method attributes

Defined in FusionFramework (HttpMethodAttributes.cs). Each takes a route template in the constructor:

AttributeHTTP method
[HttpGet]GET
[HttpPost]POST
[HttpPut]PUT
[HttpPatch]PATCH
[HttpDelete]DELETE
[HttpHead]HEAD
[HttpOptions]OPTIONS

Named properties on every attribute: Tags, Desc, Title, Deprecated.

Shared options

PropertyBehavior
Tagsnull inherits from [Route]; non-null (including empty) overrides
DescOperation description
TitleOperation summary / title
DeprecatedMark the operation deprecated

Path joining and tokens

  • Relative templates (no leading /) join to the class [Route] base path.
  • Absolute templates starting with / ignore the class base and mount at that path.
  • [module] expands from the class name (UserModule → user).
  • [action] expands from the handler name, stripping a trailing Action / ACTION then lowercasing (UserAction → user).

Example (GET + POST)

using FusionFramework;

[Route("/api/[module]", Tags = new[] { "users" })]
public class UserModule : FusionBaseApi
{
    // Convention: GET /api/user
    public object Get() =>
        Response(new { mode = "convention" }, Status.HTTP_SUCCESS);

    // Custom: GET /api/user/test/user
    [HttpGet("test/[action]", Title = "User action")]
    public object UserAction() =>
        Response(new { mode = "custom", action = "user" }, Status.HTTP_SUCCESS);

    // Custom: POST /api/user/create/create
    [HttpPost("create/[action]", Title = "Create user", Tags = new[] { "users", "write" })]
    public object CreateAction() =>
        Response(new { created = true }, Status.HTTP_SUCCESS);

    // Absolute: DELETE /admin/users/purge
    [HttpDelete("/admin/users/purge", Deprecated = true)]
    public object Purge() =>
        Response(new { purged = true }, Status.HTTP_SUCCESS);
}

Registration

Call Route.Register<UserModule>() (or register via your host bootstrap) before Listen().

Sample: examples/custom_http_routes.cs.

On this page