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;
2using System.Collections.Generic;
3using System.Threading.Tasks;
6using Waher.Script;
8
10{
15 {
21 public AgentPostResource(string AgentResourceName,
22 params KeyValuePair<Type, Expression>[] PatternMatches)
23 : base(AgentResourceName, PatternMatches)
24 {
25 }
26
30 public virtual bool AllowsPOST => true;
31
38 public async Task POST(HttpRequest Request, HttpResponse Response)
39 {
40 if (this.Api is null)
41 throw new ServiceUnavailableException("API not available.");
42
43 Dictionary<string, IElement> Match = await this.AssertMatch(Request);
44
45 SetTransparentCorsHeaders(this, Request, Response);
46
47 await this.POST(Request, Response, Match);
48 }
49
58 public abstract Task POST(HttpRequest Request, HttpResponse Response, Dictionary<string, IElement> Parameters);
59 }
60}
Represents an HTTP request.
Definition: HttpRequest.cs:18
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:21
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 > > AssertMatch(HttpRequest Request)
Checks if content matches specification in resource.
POST Interface for HTTP resources.