Add pet action management and update requests
This commit is contained in:
+21
-1
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user