private async Task GetBuckets(S3Context ctx) { if (ctx.Http.Request.Url.Elements.Length >= 3) { Bucket bucket = _Buckets.Get(ctx.Http.Request.Url.Elements[2]); if (bucket == null) { ctx.Response.StatusCode = 404; ctx.Response.ContentType = "text/plain"; await ctx.Response.Send(); return; } else { ctx.Response.StatusCode = 200; ctx.Response.ContentType = "application/json"; await ctx.Response.Send(Common.SerializeJson(bucket, true)); return; } } else { List <Bucket> buckets = _Config.GetBuckets(); ctx.Response.StatusCode = 200; ctx.Response.ContentType = "application/json"; await ctx.Response.Send(Common.SerializeJson(buckets, true)); return; } }