2018-03-20 16:03:28 +11:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace k8s.Tests.Mock.Server
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Startup logic for the KubeClient WebSockets test server.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class Startup
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2020-11-22 14:52:09 -08:00
|
|
|
/// Initializes a new instance of the <see cref="Startup"/> class.
|
2018-03-20 16:03:28 +11:00
|
|
|
/// Create a new <see cref="Startup"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Startup()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Configure application services.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="services">
|
|
|
|
|
/// The service collection to configure.
|
|
|
|
|
/// </param>
|
2020-10-23 08:31:57 -07:00
|
|
|
public static void ConfigureServices(IServiceCollection services)
|
2018-03-20 16:03:28 +11:00
|
|
|
{
|
|
|
|
|
if (services == null)
|
2020-04-23 11:40:06 -07:00
|
|
|
{
|
2018-03-20 16:03:28 +11:00
|
|
|
throw new ArgumentNullException(nameof(services));
|
2020-04-23 11:40:06 -07:00
|
|
|
}
|
2018-03-20 16:03:28 +11:00
|
|
|
|
|
|
|
|
services.AddLogging(logging =>
|
|
|
|
|
{
|
|
|
|
|
logging.ClearProviders(); // Logger provider will be added by the calling test.
|
|
|
|
|
});
|
2020-12-13 19:55:27 -08:00
|
|
|
services.AddMvc(opt => opt.EnableEndpointRouting = false);
|
2018-03-20 16:03:28 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Configure the application pipeline.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="app">
|
|
|
|
|
/// The application pipeline builder.
|
|
|
|
|
/// </param>
|
2020-10-23 08:31:57 -07:00
|
|
|
public static void Configure(IApplicationBuilder app)
|
2018-03-20 16:03:28 +11:00
|
|
|
{
|
|
|
|
|
app.UseWebSockets(new WebSocketOptions
|
|
|
|
|
{
|
|
|
|
|
KeepAliveInterval = TimeSpan.FromSeconds(5),
|
|
|
|
|
});
|
|
|
|
|
app.UseMvc();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|