Skip to content

Commit 8e4b3c7

Browse files
committed
#440 api: add cors, presence endpoint
1 parent 7a8b897 commit 8e4b3c7

File tree

2 files changed

+25
-0
lines changed
  • MiniSpace.Services.Students/src

2 files changed

+25
-0
lines changed

MiniSpace.Services.Students/src/MiniSpace.Services.Students.Api/Program.cs

+19
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,28 @@ public static async Task Main(string[] args)
3535
.AddInfrastructure();
3636

3737
services.AddGrpc();
38+
39+
services.AddCors(options =>
40+
{
41+
options.AddPolicy("CorsPolicy",
42+
builder => builder
43+
.AllowAnyMethod()
44+
.AllowAnyHeader()
45+
.AllowCredentials()
46+
.SetIsOriginAllowed(host => true));
47+
});
48+
49+
services.AddSignalR();
3850
})
3951
.Configure(app => app
4052
.UseInfrastructure()
53+
.UseCors("CorsPolicy")
54+
.UseEndpoints(endpoints =>
55+
{
56+
endpoints.MapGrpcService<StudentServiceGrpc>();
57+
endpoints.MapHub<MiniSpace.Services.Students.Application.Hubs.PresenceHub>("/presenceHub")
58+
.RequireCors("CorsPolicy");
59+
})
4160
.UseDispatcherEndpoints(endpoints => endpoints
4261
.Get("", ctx => ctx.Response.WriteAsync(ctx.RequestServices.GetService<AppOptions>().Name))
4362
.Get<GetStudents, Application.Queries.PagedResult<StudentDto>>("students")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace MiniSpace.Services.Students.Application.Hubs;
2+
3+
public class PresenceHub
4+
{
5+
6+
}

0 commit comments

Comments
 (0)