Kodice.RapidAPI.Functions.Inprocess 1.1.3

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Kodice.RapidAPI.Functions.Inprocess --version 1.1.3
NuGet\Install-Package Kodice.RapidAPI.Functions.Inprocess -Version 1.1.3
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="Kodice.RapidAPI.Functions.Inprocess" Version="1.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kodice.RapidAPI.Functions.Inprocess --version 1.1.3
#r "nuget: Kodice.RapidAPI.Functions.Inprocess, 1.1.3"
#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 Kodice.RapidAPI.Functions.Inprocess as a Cake Addin
#addin nuget:?package=Kodice.RapidAPI.Functions.Inprocess&version=1.1.3

// Install Kodice.RapidAPI.Functions.Inprocess as a Cake Tool
#tool nuget:?package=Kodice.RapidAPI.Functions.Inprocess&version=1.1.3

Kodice.RapidAPI.Functions.Inprocess

Kodice.RapidAPI.Functions.Inprocess has been designed to promote the reuse of common and repetitive code required for authorizing and handling Rapid (former RapidAPI) calls to your functions.

About the Project

As an example, if we want to use a new API with Azure Function Inprocess .NET 8 on Azure and integrate it with Rapid (former RapidAPI), there are certain steps that we must follow. Usually these steps are quite tedious, repetitive, and prone to error.

  • Validate the Secret Key sent via RapidAPI request headers.
  • Check if the Customer performing the request has the right to request a specific feature.

Getting Started

Installing Kodice.RapidAPI.Functions.Inprocess

dotnet add package Kodice.RapidAPI.Functions.Inprocess

Project status

Environment Status
Development Build Status
Production Build Status

Usage

Azure Functions V1

A .NET project for Azure Functions using the Inprocess worker model is basically a .NET console app project that targets a supported .NET runtime.

A simple example on how to add the Kodice.RapidAPI to your API project.

[Function(nameof(Create))]
public static async Task<IActionResult> Create(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "v1/create")] HttpRequest req, ILogger log)
{
    //  Create your subscription / feature mapping
    SubscriptionCollection roles = new SubscriptionCollection();
    roles.Add(SubscriptionTypes.BASIC, new Feature("TEST-A"));
    roles.Add(SubscriptionTypes.BASIC, new Feature("TEST-B"));
    roles.Add(SubscriptionTypes.PRO, new Feature("TEST-C"));

    //  Set your Secret, User, etc.
    RapidHeadersValues values = new RapidHeadersValues()
    {
        ProxySecret = "MYSECRET"
    };

    var rapid = req.GetRapid(roles);

    //  Check if proxy secret matches
    //  You can also check for other parameters - Subscriptions later on
    //  You should not proceed beyond this point in a real scenario
    var hasSecurity = rapid.IsSecure((headers, values) =>
    {
        return (headers.ProxySecret == values.ProxySecret);
    },
    values);

    //  Checking simply for Subscription, for Feature in Subscription, or for Subscription and Feature

    //  These will succeed
    var hasSub = rapid.HasSubscription(SubscriptionTypes.BASIC);
    var hasFtAllA = rapid.HasFeature("TEST-A");
    var hasFtAllB = rapid.HasFeature("TEST-B");
    var hasFtAllC = rapid.HasFeature("TEST-C");
    var hasFtProC = rapid.HasFeature(SubscriptionTypes.PRO, "TEST-C");

    //  These will fail
    var hasFtProA = rapid.HasFeature(SubscriptionTypes.PRO, "TEST-A");
    var hasFtAllX = rapid.HasFeature("TEST");

    //  If everything is OK keep going
}

Support and Sponsor

Offer me a coffee Please consider supporting the development with a little help, just a coffee

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.3 153 1/7/2024
1.1.1 91 1/6/2024