Ejemplo n.º 1
0
        public async Task List(HttpProcessor arg)
        {
            if (arg.Request.Query.ContainsKey("dir"))
            {
                var dir = arg.Request.Query["dir"];
                if (!string.IsNullOrWhiteSpace(dir))
                {
                    if (!dir.EndsWith("\\"))
                    {
                        dir += "\\";
                    }

                    var dirInfos = Directory.GetFiles(dir).Select(x =>
                    {
                        var attr = new System.IO.DirectoryInfo(x);
                        return new StorageItemInfo(attr);
                    }).ToList();

                    await arg.WriteJson(dirInfos);
                    return;
                }
            }

            await arg.WriteFail(HttpStatusCode.BadRequest);
        }
Ejemplo n.º 2
0
        public override async Task HandlePOSTRequest(HttpProcessor p)
        {
            Console.WriteLine("{0} {1}", p.Request.Method, p.Request.URL);

            var action = RouteHelper.ResolvePost(p.Request.URL);

            if (action == null)
            {
                await p.WriteFail(HttpStatusCode.NotFound);
                return;
            }

            await action.Invoke(p);
        }