コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: UpdateHandler.cs プロジェクト: solyutor/hlcup2018
 private static void BadRequest(HttpContext context, AccountStub stub)
 {
     context.Response.StatusCode = StatusCodes.Status400BadRequest;
     UpdatePool.Return(stub);
 }