Created
May 31, 2025 09:37
-
-
Save renatogroffe/79d882bb6bed0457aefa58d236ddd3f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.Json; | |
var builder = WebApplication.CreateBuilder(args); | |
builder.Services.AddOpenApi(); | |
var app = builder.Build(); | |
if (app.Environment.IsDevelopment()) | |
{ | |
app.MapOpenApi(); | |
app.MapOpenApi("/openapi/{documentName}.yaml"); | |
} | |
app.MapGet("/saudacao", () => | |
{ | |
var currentDate = DateTime.Now; | |
string mensagem = (currentDate.DayOfWeek == DayOfWeek.Saturday || | |
currentDate.DayOfWeek == DayOfWeek.Sunday) ? "Bom final de semana!" : "Seguimos na luta!"; | |
var saudacao = new Saudacao(currentDate, mensagem); | |
app.Logger.LogInformation($"Gerado objeto: {JsonSerializer.Serialize(saudacao)}"); | |
return saudacao; | |
}) | |
.WithName("GetSaudacao"); | |
app.Run(); | |
internal record Saudacao(DateTime DataAtual, string Mensagem); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment