-
Notifications
You must be signed in to change notification settings - Fork 4
/
search.cs
56 lines (49 loc) · 1.71 KB
/
search.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using System.Collections.Specialized;
using System.Linq;
using System.IO;
using Xenhey.BPM.Core.Net8.Implementation;
using Xenhey.BPM.Core.Net8;
using Microsoft.Azure.Functions.Worker;
namespace AzureServiceBusToSQL
{
public class Search
{
private readonly ILogger _logger;
public Search(ILogger<Search> logger)
{
_logger = logger;
}
private HttpRequest _req;
private NameValueCollection nvc = new NameValueCollection();
[Function("search")]
public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)]
HttpRequest req)
{
_req = req;
_logger.LogInformation("C# HTTP trigger function processed a request.");
string requestBody = await new StreamReader(_req.Body).ReadToEndAsync();
_req.Headers.ToList().ForEach(item => { nvc.Add(item.Key, item.Value.FirstOrDefault()); });
var results = orchrestatorService.Run(requestBody);
return resultSet(results);
}
private ActionResult resultSet(string reponsePayload)
{
var returnContent = new ContentResult();
var mediaSelectedtype = nvc.Get("Content-Type");
returnContent.Content = reponsePayload;
returnContent.ContentType = mediaSelectedtype;
return returnContent;
}
private IOrchestrationService orchrestatorService
{
get
{
return new ManagedOrchestratorService(nvc);
}
}
}
}