Startup.cs 810 B

12345678910111213141516171819202122232425262728
  1. using EasyRpc.AspNetCore.Serializers;
  2. using EasyRpc.AspNetCore.Utf8Json;
  3. namespace Benchmarks
  4. {
  5. using EasyRpc.AspNetCore;
  6. using Microsoft.AspNetCore.Builder;
  7. using Microsoft.Extensions.DependencyInjection;
  8. public class Startup
  9. {
  10. public void ConfigureServices(IServiceCollection services)
  11. {
  12. services.AddRpcServices(registerJsonSerializer: false);
  13. services.AddSingleton<IContentSerializer, Utf8JsonContentSerializer>();
  14. }
  15. public void Configure(IApplicationBuilder app)
  16. {
  17. app.UseRpcServices(api =>
  18. {
  19. api.GetMethod("/plaintext", () => "Hello, World!").Raw("text/plain");
  20. api.GetMethod("/json", () => new { message = "Hello, World!" });
  21. });
  22. }
  23. }
  24. }