Beispiel #1
0
        public static unsafe void Process(HttpContext context, uint accountId)
        {
            var contentLength = (int)context.Request.ContentLength;
            var pctx          = new ParseContext(Buffer.My, contentLength);

            context.ReadBytes(pctx);

            AccountStub stub = UpdatePool.RentStub();

            stub.id = accountId;

            if (!TryParseAccountUpdate(ref pctx, stub))
            {
                BadRequest(context, stub);
                return;
            }

            if (!stub.email.IsEmpty)
            {
                Account account  = Database.GetAccount(accountId);
                Email   previous = account.Email;
                Database.Replace(previous, stub.email);
            }

            UpdateWorker.Update(stub);

            context.Response.StatusCode    = StatusCodes.Status202Accepted;
            context.Response.ContentLength = 2;
            context.Response.Body.Write(NewHandler.Empty);
        }
Beispiel #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);
            }
        }