Darkspark.Dotnet.Core.Plug
1.3.0
dotnet add package Darkspark.Dotnet.Core.Plug --version 1.3.0
NuGet\Install-Package Darkspark.Dotnet.Core.Plug -Version 1.3.0
<PackageReference Include="Darkspark.Dotnet.Core.Plug" Version="1.3.0" />
paket add Darkspark.Dotnet.Core.Plug --version 1.3.0
#r "nuget: Darkspark.Dotnet.Core.Plug, 1.3.0"
// Install Darkspark.Dotnet.Core.Plug as a Cake Addin #addin nuget:?package=Darkspark.Dotnet.Core.Plug&version=1.3.0 // Install Darkspark.Dotnet.Core.Plug as a Cake Tool #tool nuget:?package=Darkspark.Dotnet.Core.Plug&version=1.3.0
Darkspark Dotnet Core Plug
This project will allow you to capture and analyse any request/response data on your controllers.
Getting Started
The following steps are required to begin observation:
- Get a Darkspark API key - see details here
- Add Darkspark Dotnet Core Plug package to your project
- Set Darkspark configuration values
- Enable request buffering (if not already done)
- Decorate the controllers/methods to observe
- Optionally set the logging level
Get Darkspark API key
You can get an API key by following the following guide: https://darkspark.io/documentation/.api-create
Set the Darkspark configuration values
Configuration values can be set in standard dotnet configuration locations (appsettings.json and environment variable examples given below).
See [Microsoft documentation link][https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?tabs=basicconfiguration&view=aspnetcore-7.0#commandline-configuration-provider] for full documentation and precedence order.
- API_KEY [Required] - The Darkspark ApiKey for this application
- NODE_LOCATION [Optional] - The location of the node executable on the system.
- Defaults to "node"
- SCRIPT_LOCATION [Optional] - As part of the build process, the relevant script file is placed in a Darkspark folder relative to the bin files. If you wish to locate the script file elsewhere, it can be specified here
- Defaults to "./Darkspark/darkspark_core.js"
Example configuration (appsettings.json)
{
"Darkspark": {
"API_KEY": "key-aaaaaaa",
"NODE_LOCATION": "c:\\temp\\node.exe",
"SCRIPT_LOCATION": "./ExternalScripts/ds.js"
}
}
Example configuration (environment variable - note the required Darkspark__ prefix)
export Darkspark__API_KEY=key-abc
export Darkspark__NODE_LOCATION=mySpecialNode
export Darkspark__SCRIPT_LOCATION=../scripts/here.js
Enable request buffering
To allow the Darkspark dotnet core plug to work, it is necessary to enable request buffering so that the body can be read more than once.
This is done by adding the following to the configure method of the startup.cs (or equivalent). Note in this context, app is an IApplicationBuilder.
app.Use(async (context, next) =>
{
context.Request.EnableBuffering();
await next();
});
Decorate the controllers/methods to enable
To enable observation, it is simply a case of adding the [Darkspark] attribute at either the Controller level or at an individual method.
Optionally set the logging level
Logging can be set on the Darkspark namespace if a level other than the application default is required. For example, to enable DEBUG level logging - use the following:
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Darkspark": "Debug"
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.Extensions.Configuration (>= 6.0.1)
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 6.0.1)
- Microsoft.Extensions.Configuration.FileExtensions (>= 6.0.0)
- Microsoft.Extensions.Configuration.Json (>= 6.0.0)
- Microsoft.Extensions.Primitives (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.2)
- System.Configuration.ConfigurationManager (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.