in src/WebJobs.Extensions.Http/HttpTriggerAttributeBindingProvider.cs [131:184]
public async Task<ITriggerData> BindAsync(object value, ValueBindingContext context)
{
HttpRequest request = value as HttpRequest;
if (request == null)
{
throw new NotSupportedException("An HttpRequest is required");
}
IValueProvider valueProvider = null;
string invokeString = ToInvokeString(request);
if (_isUserTypeBinding)
{
valueProvider = await CreateUserTypeValueProvider(request, invokeString);
}
else
{
valueProvider = new HttpRequestValueBinder(_parameter, request, invokeString);
}
object poco = null;
if (_bindingDataProvider != null)
{
// some binding data is defined by the user type
// the provider might be null if the Type is invalid, or if the Type
// has no public properties to bind to
poco = await valueProvider.GetValueAsync();
}
string body = null;
if (IsRequestPayloadReadable(request))
{
body = await request.ReadAsStringAsync();
}
IReadOnlyDictionary<string, object> bindingData = null;
if (poco != null)
{
// We're binding to a POCO, so we can't defer binding data resolution.
// We must apply it now to the POCO instance.
bindingData = GetBindingData(request, poco, body);
}
else
{
// In all other cases, binding data resolution can be deferred until it
// is requested by the binding pipeline. In many cases it won't be (e.g.
// if no other input/output bindings are used).
bindingData = new LazyBindingData(() => GetBindingData(request, poco, body));
}
return new TriggerData(valueProvider, bindingData)
{
ReturnValueProvider = new ResponseHandler(request, _options?.Value.SetResponse)
};
}