OpenSky.AspNetCore
1.0.0
dotnet add package OpenSky.AspNetCore --version 1.0.0
NuGet\Install-Package OpenSky.AspNetCore -Version 1.0.0
<PackageReference Include="OpenSky.AspNetCore" Version="1.0.0" />
paket add OpenSky.AspNetCore --version 1.0.0
#r "nuget: OpenSky.AspNetCore, 1.0.0"
// Install OpenSky.AspNetCore as a Cake Addin #addin nuget:?package=OpenSky.AspNetCore&version=1.0.0 // Install OpenSky.AspNetCore as a Cake Tool #tool nuget:?package=OpenSky.AspNetCore&version=1.0.0
OpenSky.AspNetCore
This package provides an extension method for adding the OpenSkyService
to the service collection in an ASP.NET Core project.
Also, you can use OpenSky.Core package for your console applications or other types of projects.
Configuration
Create a configuration file or set environment variables for the API key and other settings.
Usage
Example Usage for Dependency Injection
Here is an example of how to configure and use the OpenSkyService
with dependency injection in an ASP.NET Core project:
- Configure the service in
Startup.cs
orProgram.cs
:
using OpenSky.AspNetCore.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOssClient(e =>
{
e.ApiKey = "your-api-key";
});
- Inject and use the service in your controllers or services:
using Microsoft.AspNetCore.Mvc;
using OpenSky.Core.Service;
[ApiController]
[Route("[controller]")]
public class WeatherController : ControllerBase
{
private readonly IOpenSkyService _openSkyService;
public WeatherController(IOpenSkyService openSkyService)
{
_openSkyService = openSkyService;
}
[HttpGet("{location}")]
public async Task<IActionResult> GetWeather(string location)
{
var response = await _openSkyService.SearchAsync(location);
if (response.IsSuccess)
{
return Ok(response.Value);
}
return BadRequest(response.Error.Message);
}
}
This example demonstrates how to configure the OpenSkyService
using dependency injection and how to use it in an ASP.NET Core controller to search for weather information.
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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Http (>= 9.0.0)
- OpenSky.Core (>= 1.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.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 69 | 12/24/2024 |