public static unsafe void Process(HttpContext context) { var contentLength = (int)context.Request.ContentLength; var pctx = new ParseContext(Buffer.My, contentLength); context.ReadBytes(pctx); if (!TryParseLikes(ref pctx, out HList <NewLike> result)) { if (result != null) { UpdatePool.Return(result); } BadRequest(context); return; } if (result != null) { UpdateWorker.AddLikes(result); } context.Response.StatusCode = StatusCodes.Status202Accepted; context.Response.ContentLength = 2; context.Response.Body.Write(NewHandler.Empty); }
public static void Process(HttpContext context) { var contentLength = (int)context.Request.ContentLength; var pctx = new ParseContext(Buffer.My, contentLength); context.ReadBytes(pctx); var stub = UpdatePool.RentStub(); var statusCode = TryParseAccount(ref pctx, stub); context.Response.StatusCode = statusCode; if (statusCode == 201) { context.Response.ContentLength = Empty.Length; context.Response.Body.Write(Empty); UpdateWorker.AddNew(Database.InsertFromPost(stub)); } else { UpdatePool.Return(stub); } }
private static void BadRequest(HttpContext context, AccountStub stub) { context.Response.StatusCode = StatusCodes.Status400BadRequest; UpdatePool.Return(stub); }