You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.6 KiB
76 lines
2.6 KiB
3 years ago
|
using ApiBasicAuth.Security;
|
||
|
using Microsoft.AspNetCore.Authentication;
|
||
|
using Microsoft.AspNetCore.Builder;
|
||
|
using Microsoft.AspNetCore.Hosting;
|
||
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
|
||
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
using Microsoft.Extensions.Hosting;
|
||
|
using Microsoft.Extensions.Logging;
|
||
|
using Microsoft.OpenApi.Models;
|
||
|
|
||
|
namespace Win_in.Sfs.Scp.WebApi.XmlHost
|
||
|
{
|
||
|
public class Startup
|
||
|
{
|
||
|
public void ConfigureServices(IServiceCollection services)
|
||
|
{
|
||
|
// services.AddControllers()
|
||
|
// .AddXmlDataContractSerializerFormatters();
|
||
|
|
||
|
var configuration = services.GetConfiguration();
|
||
|
|
||
|
services.AddControllers()
|
||
|
.AddMvcOptions(options =>
|
||
|
{
|
||
|
// options.ModelMetadataDetailsProviders.Add(
|
||
|
// new ExcludeBindingMetadataProvider(typeof(System.Version)));
|
||
|
// options.ModelMetadataDetailsProviders.Add(
|
||
|
// new SuppressChildValidationMetadataProvider(typeof(System.Guid)));
|
||
|
options.InputFormatters.Insert(0, new XDocumentInputFormatter());
|
||
|
// options.OutputFormatters.Insert(0,new XDocumentOutputFormatter());
|
||
|
})
|
||
|
.AddXmlDataContractSerializerFormatters()
|
||
|
.AddXmlSerializerFormatters();
|
||
|
|
||
|
|
||
|
// services.AddControllers();
|
||
|
services.AddSwaggerGen(c =>
|
||
|
{
|
||
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Win_in.Sfs.Scp.WebApi.Xml.Host", Version = "v1" });
|
||
|
});
|
||
|
|
||
|
services.AddAuthentication("BasicAuthentication")
|
||
|
.AddScheme<AuthenticationSchemeOptions, BasicAuthenticationHandler>("BasicAuthentication", null);
|
||
|
|
||
|
services.Configure<BasicAuthenticationOptions>(configuration.GetSection("BasicAuthentication"));
|
||
|
|
||
|
services.AddSingleton(typeof(IHttpClientInvoker<,>),typeof(HttpClientInvoker<,>));
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
||
|
{
|
||
|
if (env.IsDevelopment())
|
||
|
{
|
||
|
app.UseDeveloperExceptionPage();
|
||
|
}
|
||
|
|
||
|
app.UseSwagger();
|
||
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Win_in.Sfs.Scp.WebApi.Xml.Host v1"));
|
||
|
|
||
|
app.UseRouting();
|
||
|
|
||
|
app.UseAuthentication();
|
||
|
app.UseAuthorization();
|
||
|
|
||
|
|
||
|
app.UseEndpoints(endpoints =>
|
||
|
{
|
||
|
endpoints.MapControllers();
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|