本文整理汇总了C#中IHttpContext.SetStatusToDeleted方法的典型用法代码示例。如果您正苦于以下问题:C# IHttpContext.SetStatusToDeleted方法的具体用法?C# IHttpContext.SetStatusToDeleted怎么用?C# IHttpContext.SetStatusToDeleted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHttpContext
的用法示例。
在下文中一共展示了IHttpContext.SetStatusToDeleted方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Respond
public override void Respond(IHttpContext context)
{
var match = urlMatcher.Match(context.GetRequestUrl());
var index = match.Groups[1].Value;
switch (context.Request.HttpMethod)
{
case "HEAD":
if(Database.IndexDefinitionStorage.IndexNames.Contains(index, StringComparer.InvariantCultureIgnoreCase) == false)
context.SetStatusToNotFound();
break;
case "GET":
OnGet(context, index);
break;
case "PUT":
Put(context, index);
break;
case "RESET":
Database.ResetIndex(index);
context.WriteJson(new {Reset = index});
break;
case "DELETE":
context.SetStatusToDeleted();
Database.DeleteIndex(index);
break;
}
}
示例2: Respond
public override void Respond(IHttpContext context)
{
var match = urlMatcher.Match(context.GetRequestUrl());
var docId = match.Groups[1].Value;
switch (context.Request.HttpMethod)
{
case "GET":
Get(context, docId);
break;
case "DELETE":
Database.Delete(docId, context.GetEtag(), GetRequestTransaction(context));
context.SetStatusToDeleted();
break;
case "PUT":
Put(context, docId);
break;
case "PATCH":
var patchRequestJson = context.ReadJsonArray();
var patchRequests = patchRequestJson.Cast<RavenJObject>().Select(PatchRequest.FromJson).ToArray();
var patchResult = Database.ApplyPatch(docId, context.GetEtag(), patchRequests, GetRequestTransaction(context));
switch (patchResult)
{
case PatchResult.DocumentDoesNotExists:
context.SetStatusToNotFound();
break;
case PatchResult.Patched:
context.Response.AddHeader("Location", Database.Configuration.GetFullUrl("/docs/" + docId));
context.WriteJson(new {Patched = true});
break;
default:
throw new ArgumentOutOfRangeException("Value " + patchResult + " is not understood");
}
break;
}
}
示例3: Respond
public override void Respond(IHttpContext context)
{
var match = urlMatcher.Match(context.GetRequestUrl());
var filename = match.Groups[1].Value;
var etag = context.GetEtag();
switch (context.Request.HttpMethod)
{
case "GET":
var attachmentAndHeaders = Database.GetStatic(filename);
if (attachmentAndHeaders == null)
{
context.SetStatusToNotFound();
return;
}
if (context.MatchEtag(attachmentAndHeaders.Etag))
{
context.SetStatusToNotModified();
return;
}
context.WriteData(attachmentAndHeaders.Data, attachmentAndHeaders.Metadata,
attachmentAndHeaders.Etag);
break;
case "PUT":
Database.PutStatic(filename, context.GetEtag(), context.Request.InputStream.ReadData(),
context.Request.Headers.FilterHeaders(isServerDocument:false));
context.SetStatusToCreated("/static/" + filename);
break;
case "DELETE":
Database.DeleteStatic(filename, etag);
context.SetStatusToDeleted();
break;
}
}
示例4: Respond
public override void Respond(IHttpContext context)
{
var match = urlMatcher.Match(context.GetRequestUrl());
var docId = Uri.UnescapeDataString(match.Groups[1].Value);
switch (context.Request.HttpMethod)
{
case "HEAD":
Head(context, docId);
break;
case "GET":
Get(context, docId);
break;
case "DELETE":
Database.Delete(docId, context.GetEtag(), GetRequestTransaction(context));
context.SetStatusToDeleted();
break;
case "PUT":
Put(context, docId);
break;
case "PATCH":
var patchRequestJson = context.ReadJsonArray();
var patchRequests = patchRequestJson.Cast<RavenJObject>().Select(PatchRequest.FromJson).ToArray();
var patchResult = Database.ApplyPatch(docId, context.GetEtag(), patchRequests, GetRequestTransaction(context));
ProcessPatchResult(context, docId, patchResult.PatchResult, null);
break;
case "EVAL":
var advPatchRequestJson = context.ReadJsonObject<RavenJObject>();
var advPatch = ScriptedPatchRequest.FromJson(advPatchRequestJson);
var advPatchResult = Database.ApplyPatch(docId, context.GetEtag(), advPatch, GetRequestTransaction(context), true);
ProcessPatchResult(context, docId, advPatchResult.Item1.PatchResult, advPatchResult.Item2);
break;
}
}
示例5: Respond
public override void Respond(IHttpContext context)
{
var match = urlMatcher.Match(context.GetRequestUrl());
var index = match.Groups[1].Value;
switch (context.Request.HttpMethod)
{
case "HEAD":
if(Database.IndexDefinitionStorage.IndexNames.Contains(index, StringComparer.InvariantCultureIgnoreCase) == false)
context.SetStatusToNotFound();
break;
case "GET":
OnGet(context, index);
break;
case "PUT":
Put(context, index);
break;
case "DELETE":
if(index.StartsWith("Raven/",StringComparison.InvariantCultureIgnoreCase))
{
context.SetStatusToForbidden();
context.WriteJson(new
{
Url = context.Request.RawUrl,
Error = "Builtin indexes cannot be deleted, attempt to delete index '" + index + "' was rejected"
});
return;
}
context.SetStatusToDeleted();
Database.DeleteIndex(index);
break;
}
}
示例6: Respond
public override void Respond(IHttpContext context)
{
var match = urlMatcher.Match(context.GetRequestUrl());
var filename = match.Groups[1].Value;
var etag = context.GetEtag();
switch (context.Request.HttpMethod)
{
case "GET":
Database.TransactionalStorage.Batch(_=> // have to keep the session open for reading of the attachment stream
{
var attachmentAndHeaders = Database.GetStatic(filename);
if (attachmentAndHeaders == null)
{
context.SetStatusToNotFound();
return;
}
if (context.MatchEtag(attachmentAndHeaders.Etag))
{
context.SetStatusToNotModified();
return;
}
context.WriteHeaders(attachmentAndHeaders.Metadata, attachmentAndHeaders.Etag);
using (var stream = attachmentAndHeaders.Data())
{
stream.CopyTo(context.Response.OutputStream);
}
});
break;
case "HEAD":
Database.TransactionalStorage.Batch(_ => // have to keep the session open for reading of the attachment stream
{
var attachmentAndHeaders = Database.GetStatic(filename);
if (attachmentAndHeaders == null)
{
context.SetStatusToNotFound();
return;
}
if (context.MatchEtag(attachmentAndHeaders.Etag))
{
context.SetStatusToNotModified();
return;
}
context.WriteHeaders(attachmentAndHeaders.Metadata, attachmentAndHeaders.Etag);
context.Response.ContentLength64 = attachmentAndHeaders.Size;
});
break;
case "PUT":
var newEtag = Database.PutStatic(filename, context.GetEtag(), context.Request.InputStream,
context.Request.Headers.FilterHeaders(isServerDocument:false));
context.WriteETag(newEtag);
context.SetStatusToCreated("/static/" + filename);
break;
case "DELETE":
Database.DeleteStatic(filename, etag);
context.SetStatusToDeleted();
break;
}
}
示例7: Respond
public override void Respond(IHttpContext context)
{
var match = urlMatcher.Match(context.GetRequestUrl());
var docId = match.Groups[1].Value;
switch (context.Request.HttpMethod)
{
case "GET":
context.Response.Headers["Content-Type"] = "application/json; charset=utf-8";
var doc = Database.Get(docId,GetRequestTransaction(context));
if (doc == null)
{
context.SetStatusToNotFound();
return;
}
if(doc.NonAuthoritiveInformation)
{
context.SetStatusToNonAuthoritiveInformation();
}
if (context.MatchEtag(doc.Etag))
{
context.SetStatusToNotModified();
return;
}
doc.Metadata["Last-Modified"] = doc.LastModified.ToString("r");
context.WriteData(doc.DataAsJson, doc.Metadata, doc.Etag);
break;
case "DELETE":
Database.Delete(docId, context.GetEtag(), GetRequestTransaction(context));
context.SetStatusToDeleted();
break;
case "PUT":
Put(context, docId);
break;
case "PATCH":
var patchRequestJson = context.ReadJsonArray();
var patchRequests = patchRequestJson.Cast<JObject>().Select(PatchRequest.FromJson).ToArray();
var patchResult = Database.ApplyPatch(docId, context.GetEtag(), patchRequests, GetRequestTransaction(context));
switch (patchResult)
{
case PatchResult.DocumentDoesNotExists:
context.SetStatusToNotFound();
break;
case PatchResult.Patched:
context.Response.Headers["Location"] = Database.Configuration.GetFullUrl("/docs/" + docId);
context.WriteJson(new {Patched = true});
break;
default:
throw new ArgumentOutOfRangeException("Value " + patchResult + " is not understood");
}
break;
}
}
示例8: Respond
public override void Respond(IHttpContext context)
{
var match = urlMatcher.Match(context.GetRequestUrl());
var transformer = match.Groups[1].Value;
switch (context.Request.HttpMethod)
{
case "GET":
if (string.IsNullOrEmpty(transformer) == false && transformer != "/")
{
var transformerDefinition = Database.GetTransformerDefinition(transformer);
if (transformerDefinition == null)
{
context.SetStatusToNotFound();
return;
}
context.WriteJson(new
{
Transformer = transformerDefinition,
});
break;
}
var namesOnlyString = context.Request.QueryString["namesOnly"];
bool namesOnly;
RavenJArray transformers;
if (bool.TryParse(namesOnlyString, out namesOnly) && namesOnly)
transformers = Database.GetTransformerNames(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize));
else
transformers = Database.GetTransformers(context.GetStart(), context.GetPageSize(Database.Configuration.MaxPageSize));
context.WriteJson(transformers);
break;
case "PUT":
HandlePut(context, transformer);
break;
case "DELETE":
context.SetStatusToDeleted();
Database.DeleteTransfom(transformer);
break;
}
}