Пример #1
0
 Task Key(IOwinContext context, IDictionary<string, string> parameters)
 {
     var key = parameters["key"];
     switch (context.Request.Method)
     {
         case "GET":
             var entity = this.db.Get(key);
             return context.ReturnJsonString(entity.Value);
         case "POST":
         case "PUT":
             using (var reader = new StreamReader(context.Request.Body))
             {
                 var newEntity = new Entity { Value = reader.ReadToEnd() };
                 this.db.Set(key, newEntity);
                 return context.ReturnJsonString(newEntity.Value);
             }
         case "DEL":
             this.db.Del(key);
             return Task.FromResult(0);
     }
     throw new ArgumentException("verb not supported");
 }