-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathStartup.cs
More file actions
78 lines (72 loc) · 2.5 KB
/
Startup.cs
File metadata and controls
78 lines (72 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using CoreWCF;
using CoreWCF.Configuration;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.DependencyInjection;
using Swashbuckle.AspNetCore.Swagger;
using System.Xml;
using WebHttp;
internal sealed class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddServiceModelWebServices(o =>
{
o.Title = "Test API";
o.Version = "1";
o.Description = "API Description";
o.TermsOfService = new("http://example.com/terms");
o.ContactName = "Contact";
o.ContactEmail = "support@example.com";
o.ContactUrl = new("http://example.com/contact");
o.ExternalDocumentUrl = new("http://example.com/doc.pdf");
o.ExternalDocumentDescription = "Documentation";
});
services.AddSingleton(new SwaggerOptions());
services.Configure<KestrelServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});
}
public void Configure(IApplicationBuilder app)
{
app.UseMiddleware<SwaggerMiddleware>();
app.UseSwaggerUI();
app.UseServiceModel(builder =>
{
var readerQuoates = new XmlDictionaryReaderQuotas
{
MaxBytesPerRead = 4096,
MaxDepth = 32,
MaxArrayLength = 16384,
MaxStringContentLength = 16384,
MaxNameTableCharCount = 16384
};
builder.AddService<WebApi>();
builder.AddServiceWebEndpoint<WebApi, IWebApi>(new WebHttpBinding
{
MaxReceivedMessageSize = 5242880,
MaxBufferSize = 65536,
ReaderQuotas = readerQuoates
}, "api", behavior =>
{
behavior.HelpEnabled = true;
behavior.AutomaticFormatSelectionEnabled = true;
});
builder.AddServiceWebEndpoint<WebApi, IWebApi>(new WebHttpBinding
{
Security = new WebHttpSecurity
{
Mode = WebHttpSecurityMode.Transport
},
MaxReceivedMessageSize = 5242880,
MaxBufferSize = 65536,
ReaderQuotas = readerQuoates
}, "api", behavior =>
{
behavior.HelpEnabled = true;
behavior.AutomaticFormatSelectionEnabled = true;
});
});
}
}