Add pet action management and update requests

This commit is contained in:
2025-02-01 00:29:33 -03:00
parent 4c4036a266
commit e1c5eed02d
12 changed files with 337 additions and 36 deletions
+21 -1
View File
@@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore;
using pet_companion_api.Data;
using pet_companion_api.Repositories;
using pet_companion_api.Services;
using System.Text.Json.Serialization;
namespace pet_companion_api
{
@@ -12,7 +13,11 @@ namespace pet_companion_api
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
@@ -24,6 +29,17 @@ namespace pet_companion_api
builder.Services.AddScoped<PetRepository>();
builder.Services.AddScoped<PetService>();
// Add CORS policy
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAll", builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
@@ -35,6 +51,10 @@ namespace pet_companion_api
app.UseHttpsRedirection();
app.UseAuthorization();
// Use CORS policy
app.UseCors("AllowAll");
app.MapControllers();
app.Run();
}