HopFrame.Api
1.1.0
See the version list below for details.
dotnet add package HopFrame.Api --version 1.1.0
NuGet\Install-Package HopFrame.Api -Version 1.1.0
<PackageReference Include="HopFrame.Api" Version="1.1.0" />
paket add HopFrame.Api --version 1.1.0
#r "nuget: HopFrame.Api, 1.1.0"
// Install HopFrame.Api as a Cake Addin #addin nuget:?package=HopFrame.Api&version=1.1.0 // Install HopFrame.Api as a Cake Tool #tool nuget:?package=HopFrame.Api&version=1.1.0
HopFrame API module
This module contains some useful endpoints for user login / register management.
Ho to use the Web API version
Add the HopFrame.Api library to your project:
dotnet add package HopFrame.Api
Create a DbContext that inherits the
HopDbContext
and add a data sourcepublic class DatabaseContext : HopDbContextBase { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { base.OnConfiguring(optionsBuilder); optionsBuilder.UseSqlite("..."); } }
Add the DbContext and HopFrame to your services
builder.Services.AddDbContext<DatabaseContext>(); builder.Services.AddHopFrame<DatabaseContext>();
Endpoints
By default, the module provides a controller for handling authentication based requests by the user. You can explore the contoller by the build in swagger site from ASP .NET.
Disable the Endpoints
builder.Services.AddDbContext<DatabaseContext>();
//builder.Services.AddHopFrame<DatabaseContext>();
services.AddHopFrameNoEndpoints<TDbContext>();
Services added in this module
You can use these services by specifying them as a dependency. All of them are scoped dependencies.
LogicResult
Logic result is an extension of the ActionResult for an ApiController. It provides simple Http status results with either a message or data by specifying the generic type.
public class LogicResult : ILogicResult {
public static LogicResult Ok();
public static LogicResult BadRequest();
public static LogicResult BadRequest(string message);
public static LogicResult Forbidden();
public static LogicResult Forbidden(string message);
public static LogicResult NotFound();
public static LogicResult NotFound(string message);
public static LogicResult Conflict();
public static LogicResult Conflict(string message);
public static LogicResult Forward(LogicResult result);
public static LogicResult Forward<T>(ILogicResult<T> result);
public static implicit operator ActionResult(LogicResult v);
}
public class LogicResult<T> : ILogicResult<T> {
public static LogicResult<T> Ok();
public static LogicResult<T> Ok(T result);
...
}
IAuthLogic
This service handles all logic needed to provide the authentication endpoints by using the LogicResults.
public interface IAuthLogic {
Task<LogicResult<SingleValueResult<string>>> Login(UserLogin login);
Task<LogicResult<SingleValueResult<string>>> Register(UserRegister register);
Task<LogicResult<SingleValueResult<string>>> Authenticate();
Task<LogicResult> Logout();
Task<LogicResult> Delete(UserPasswordValidation validation);
}
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
- HopFrame.Database (>= 1.1.0)
- HopFrame.Security (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.