Kodice.RapidAPI.Functions.Inprocess
1.1.1
Prefix Reserved
See the version list below for details.
dotnet add package Kodice.RapidAPI.Functions.Inprocess --version 1.1.1
NuGet\Install-Package Kodice.RapidAPI.Functions.Inprocess -Version 1.1.1
<PackageReference Include="Kodice.RapidAPI.Functions.Inprocess" Version="1.1.1" />
paket add Kodice.RapidAPI.Functions.Inprocess --version 1.1.1
#r "nuget: Kodice.RapidAPI.Functions.Inprocess, 1.1.1"
// Install Kodice.RapidAPI.Functions.Inprocess as a Cake Addin #addin nuget:?package=Kodice.RapidAPI.Functions.Inprocess&version=1.1.1 // Install Kodice.RapidAPI.Functions.Inprocess as a Cake Tool #tool nuget:?package=Kodice.RapidAPI.Functions.Inprocess&version=1.1.1
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 | |
Production |
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.GetHeaders(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
Please consider supporting the development with a little help, just a coffee
Product | Versions 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. |
-
net8.0
- Kodice.RapidAPI.Functions.Core (>= 1.0.2)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.