예제 #1
0
 public void Configure(IApplicationBuilder app)
 {
     app.UseRouter(routes =>
     {
         routes.MapGet("api/1/{id:int}", async context =>
         {
             var payload            = EntityConstant.ToReadonlyMemory();
             var response           = context.Response;
             response.StatusCode    = StatusCodes.Status200OK;
             response.ContentLength = payload.Length;
             await response.Body.WriteAsync(payload);
         });
     });
 }
        public ValueTask ProcessRequestAsync()
        {
            var payload = EntityConstant.ToReadonlySpan();
            var writer  = GetWriter(Writer);

            // HTTP 1.1 OK
            writer.Write(_http11OK);

            // Content-Length header
            writer.Write(_headerContentLength);
            writer.WriteNumeric((uint)payload.Length);

            // End of headers
            writer.Write(_eoh);

            // Body
            writer.Write(payload);
            writer.Commit();

            return(default);
예제 #3
0
 public IActionResult Get(int id)
 => new ReadOnlyMemoryActionResult(EntityConstant.ToReadonlyMemory());