practicekea_backend/gateway/Startup.cs

79 lines
3.5 KiB
C#
Raw Normal View History

2024-12-02 13:24:34 +00:00
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
namespace OnlineAssessment.Gateway
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddOcelot();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public async void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync(GetIndexPage());
});
});
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
await app.UseOcelot();
}
public string GetIndexPage()
{
string indexPage = @"
<div style='width: 80%; display: block; margin: 100px auto; border: none; text-align:center;font-family: arial'>
<img style='height: 80px;' src='https://www.odiware.com/wp-content/uploads/2020/04/color_logo_transparent-scaled.jpg' srcset='https://www.odiware.com/wp-content/uploads/2020/04/color_logo_transparent-scaled.jpg 1x, https://www.odiware.com/wp-content/uploads/2020/04/color_logo_transparent-scaled.jpg 2x' alt='Odiware Technologies' class='logo logoDefault' />
<h3 style='color:green'>API Gateway (Online Assessment)</h3>
<ul style='list-style-type:none;'>
<li>
User API &nbsp;&nbsp;<a href='http://api-user.odiprojects.com/swagger/index.html' target='_blank'>(api-user)</a>
</li>
<li style='height: 20px'>&nbsp;</li>
<li>
Admin API&nbsp;&nbsp; <a href='http://api-admin.odiprojects.com/swagger/index.html' target='_blank'>(api-admin)</a>
</li>
<li style='height: 20px'>&nbsp;</li>
<li>
Institute API&nbsp;&nbsp; <a href='http://api-institute.odiprojects.com/swagger/index.html' target='_blank'>(api-institute)</a>
</li>
<li style='height: 20px'>&nbsp;</li>
<li>
Student API&nbsp;&nbsp; <a href='http://api-student.odiprojects.com/swagger/index.html' target='_blank'>(api-institute)</a>
</li>
<li style='height: 20px'>&nbsp;</li>
<li>
Images API&nbsp;&nbsp; <a href='http://api-bucket.odiprojects.com/swagger/index.html' target='_blank'>(api-institute)</a>
</li>
</ul>
</div>
";
return indexPage;
}
}
}