Raz.HeaderAttribute 1.0.1

dotnet add package Raz.HeaderAttribute --version 1.0.1
NuGet\Install-Package Raz.HeaderAttribute -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Raz.HeaderAttribute" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Raz.HeaderAttribute --version 1.0.1
#r "nuget: Raz.HeaderAttribute, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Raz.HeaderAttribute as a Cake Addin
#addin nuget:?package=Raz.HeaderAttribute&version=1.0.1

// Install Raz.HeaderAttribute as a Cake Tool
#tool nuget:?package=Raz.HeaderAttribute&version=1.0.1

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.HeaderAttribute
    
    • 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] string rows)
          {
              // Print in the debug window to be sure our bound stuff are passed :)
              Debug.WriteLine($"My Debugger!!! Arrrrrggggh!!!!: Rows {rows}, Page {page}");
              ...
          }
      }
    

    And with this you're all setup and good. You can star this repo if you found this useful 😃

Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 24,406 11/5/2017
1.0.0 1,370 11/4/2017

- Added ability to use parameter name as header key when header key is not specified