Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AgentPostResource.cs
1using System;
3using System.Threading.Tasks;
5using Waher.Script;
7
9{
14 {
20 public AgentPostResource(string AgentResourceName,
21 params KeyValuePair<Type, Expression>[] PatternMatches)
22 : base(AgentResourceName, PatternMatches)
23 {
24 }
25
29 public virtual bool AllowsPOST => true;
30
37 public async Task POST(HttpRequest Request, HttpResponse Response)
38 {
39 if (this.Api is null)
40 throw new ServiceUnavailableException("API not available.");
41
42 Dictionary<string, IElement> Match = await this.CheckInput(Request, Response);
43 if (Match is null)
44 return;
45
46 SetTransparentCorsHeaders(this, Request, Response);
47
48 await this.POST(Request, Response, Match);
49 }
50
59 public abstract Task POST(HttpRequest Request, HttpResponse Response, Dictionary<string, IElement> Parameters);
60 }
61}
Represents an HTTP request.
Definition: HttpRequest.cs:22
static void SetTransparentCorsHeaders(HttpResource Resource, HttpRequest Request, HttpResponse Response)
Sets CORS headers for a resource, allowing it to be embedded in other sites.
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:23
The server is currently unable to handle the request due to a temporary overloading or maintenance of...
Abstract base class for agent resources supporting the POST method.
virtual bool AllowsPOST
If the POST method is allowed.
AgentPostResource(string AgentResourceName, params KeyValuePair< Type, Expression >[] PatternMatches)
Abstract base class for agent resources supporting the POST method.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
abstract Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.
Abstract base class for agent resources
async Task< Dictionary< string, IElement > > CheckInput(HttpRequest Request, HttpResponse Response)
Checks if content matches specification in resource.
POST Interface for HTTP resources.