Startup.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using EasyRpc.AspNetCore;
  6. using EasyRpc.Services;
  7. using Microsoft.AspNetCore.Builder;
  8. using Microsoft.AspNetCore.Hosting;
  9. using Microsoft.AspNetCore.HttpsPolicy;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Microsoft.Extensions.Configuration;
  12. using Microsoft.Extensions.DependencyInjection;
  13. using Microsoft.Extensions.Hosting;
  14. using Microsoft.Extensions.Logging;
  15. namespace EasyRpc
  16. {
  17. public class Startup
  18. {
  19. public Startup(IConfiguration configuration)
  20. {
  21. Configuration = configuration;
  22. }
  23. public IConfiguration Configuration { get; }
  24. // This method gets called by the runtime. Use this method to add services to the container.
  25. public void ConfigureServices(IServiceCollection services)
  26. {
  27. services.AddJsonRpc();
  28. services.AddControllers();
  29. }
  30. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  31. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  32. {
  33. if (env.IsDevelopment())
  34. {
  35. app.UseDeveloperExceptionPage();
  36. }
  37. app.UseHttpsRedirection();
  38. app.UseRouting();
  39. app.UseAuthorization();
  40. app.UseEndpoints(endpoints =>
  41. {
  42. endpoints.MapControllers();
  43. });
  44. app.UseJsonRpc("/", api =>
  45. {
  46. // Expose methods at /IntMath
  47. api.Expose<IntMath>().As("IntMath");
  48. });
  49. }
  50. }
  51. }