Raz.HeaderAttribute 1.0.0

This package makes a FromHeader attribute available in order to get values from request header straight from controller parameters in ASP.NET WebApi

There is a newer version of this package available.
See the version list below for details.
Install-Package Raz.HeaderAttribute -Version 1.0.0
dotnet add package Raz.HeaderAttribute --version 1.0.0
<PackageReference Include="Raz.HeaderAttribute" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Raz.HeaderAttribute --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

RazHeaderAttribute

Simple dotnet package for getting values from request headers in a clean way

Instructions


Setting up and using this library/package can be done in a few simple steps

  1. Install from nuget

    You can do this using one of two ways

    • Via nuget package manager console

    Simply type in the following command in the PM console

    Install-Package Raz.HeaderAttribtue
    
    • Via nuget package manager GUI
    1. Right click on your solution
    2. click on the nuget package manager
    3. search for Raz.HeaderAttribute
    4. install :)
  2. Add the Attribute close to the controller parameter you wish to bind it to

    If you're already familiar with binding attributes this will be the simplest step. If you're not, C# has binding attributes that tell the framework where to get parameters specified in your controller from. For example, the [FromUri] attribute that tells the framework to pick that parameter from the URI or the [FromBody] one that tells the framework to pick the parameter from the request body for post requests.

    This package makes the attribute [FromHeader] available and also lets us specify the name of the header key we need and just like the pre-built attributes, it tries to bind to any primitive data type specified. Here's an example:

      ...
      using RazHeaderAttribute.Attributes;
    
      [Route("api/{controller}")]
      // Ewa-agoyin with sauce ;)
      public class YamAndBeansController : ApiController 
      {
          ...
          // GET api/yamandbeans
          [HttpGet]
          public IEnumerable<string> Get([FromHeader("page")] int page, [FromHeader("rows")] string row)
          {
              // Print in the debug window to be sure our bound stuff are passed :)
              Debug.WriteLine($"My Debugger!!! Arrrrrggggh!!!!: Rows {rows}, Page {page}");
              ...
          }
      }
    

RazHeaderAttribute

Simple dotnet package for getting values from request headers in a clean way

Instructions


Setting up and using this library/package can be done in a few simple steps

  1. Install from nuget

    You can do this using one of two ways

    • Via nuget package manager console

    Simply type in the following command in the PM console

    Install-Package Raz.HeaderAttribtue
    
    • Via nuget package manager GUI
    1. Right click on your solution
    2. click on the nuget package manager
    3. search for Raz.HeaderAttribute
    4. install :)
  2. Add the Attribute close to the controller parameter you wish to bind it to

    If you're already familiar with binding attributes this will be the simplest step. If you're not, C# has binding attributes that tell the framework where to get parameters specified in your controller from. For example, the [FromUri] attribute that tells the framework to pick that parameter from the URI or the [FromBody] one that tells the framework to pick the parameter from the request body for post requests.

    This package makes the attribute [FromHeader] available and also lets us specify the name of the header key we need and just like the pre-built attributes, it tries to bind to any primitive data type specified. Here's an example:

      ...
      using RazHeaderAttribute.Attributes;
    
      [Route("api/{controller}")]
      // Ewa-agoyin with sauce ;)
      public class YamAndBeansController : ApiController 
      {
          ...
          // GET api/yamandbeans
          [HttpGet]
          public IEnumerable<string> Get([FromHeader("page")] int page, [FromHeader("rows")] string row)
          {
              // Print in the debug window to be sure our bound stuff are passed :)
              Debug.WriteLine($"My Debugger!!! Arrrrrggggh!!!!: Rows {rows}, Page {page}");
              ...
          }
      }
    

Release Notes

- Added FromHeader Attribute

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1 10,775 11/5/2017
1.0.0 270 11/4/2017