-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScopedFunction.cs
34 lines (30 loc) · 961 Bytes
/
ScopedFunction.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
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using MediatR;
using DemoScopedDI.Actions;
namespace DemoScopedDI
{
public class ScopedFunction
{
private readonly IMediator mediator;
public ScopedFunction(IMediator mediator)
{
this.mediator = mediator;
}
[FunctionName("ScopedFunction")]
public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req)
{
var dependency = await mediator.Send(new CallScopedDependency());
//This should always return Runs 1 and a differente instance hash
return new OkObjectResult(dependency);
}
}
}