forked from sanchezvem/PyroFetes
MAJ avec l'ajout de la gestion d'authentification
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
using API.DTO.Color.Request;
|
||||
using API.DTO.Color.Response;
|
||||
using FastEndpoints;
|
||||
using PyroFetes;
|
||||
|
||||
namespace API.Endpoints.Color;
|
||||
namespace PyroFetes.Endpoints.Color;
|
||||
|
||||
public class CreateColorEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<CreateColorDto, GetColorDto> //Instanciation d'une connexion à la bdd dans un endpoint, utilise l'élément de requête CreateColorDto et l'élement de réponse GetColorDto
|
||||
{
|
||||
public override void Configure() //Configuration de l'endpoint
|
||||
{
|
||||
Post("/colors"); //Création d'un endpoint pour créer une couleur avec les données de CreateColorDto
|
||||
AllowAnonymous(); //Laisser passer les requêtes non authentifiées
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CreateColorDto req, CancellationToken ct) //La méthode HandleAsync est appelée lorsqu'une requête est envoyée à l'endpoint
|
||||
|
||||
@@ -13,7 +13,6 @@ public class DeleteColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
|
||||
public override void Configure()
|
||||
{
|
||||
Delete("/colors/{@id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(DeleteColorRequest req, CancellationToken ct)
|
||||
|
||||
@@ -9,7 +9,6 @@ public class GetAllColorsEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpo
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/colors");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
|
||||
@@ -14,7 +14,6 @@ public class GetColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoint<
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/colors/{@id}", x => new { x.Id});
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(GetColorRequest req, CancellationToken ct)
|
||||
|
||||
@@ -10,7 +10,6 @@ public class UpdateColorEndpoint(PyroFetesDbContext pyrofetesdbcontext) : Endpoi
|
||||
public override void Configure()
|
||||
{
|
||||
Put("/colors/{@id}", x => new { x.Id });
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(UpdateColorDto req, CancellationToken ct)
|
||||
|
||||
Reference in New Issue
Block a user