Init commit.
This commit is contained in:
32
OptixServe.Api/Endpoints/UserEndpoint.cs
Normal file
32
OptixServe.Api/Endpoints/UserEndpoint.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using OptixServe.Api.Dtos;
|
||||
|
||||
namespace OptixServe.Api.Endpoints;
|
||||
|
||||
|
||||
[JsonSerializable(typeof(UserDto))]
|
||||
[JsonSerializable(typeof(IEnumerable<UserDto>))]
|
||||
public partial class UserJsonContext : JsonSerializerContext { }
|
||||
|
||||
public static class UserEndpoint
|
||||
{
|
||||
public static IEnumerable<UserDto> GetUsers()
|
||||
{
|
||||
return [
|
||||
new() {Id="1234", UserName = "xxx"},
|
||||
new() {Id="5678", UserName = "yyy"},
|
||||
];
|
||||
}
|
||||
|
||||
public static void Register(WebApplication app)
|
||||
{
|
||||
var group = app.MapGroup("/users");
|
||||
|
||||
group.MapGet("/", GetAllUsers);
|
||||
}
|
||||
|
||||
public static IResult GetAllUsers()
|
||||
{
|
||||
return Results.Ok(GetUsers());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user