Skip to content

Commit dcb234a

Browse files
author
James Brundage
committed
feat(server): Positional binding improvement ( Fixes #60, Fixes #61 )
Fixing json binding
1 parent eebf2ee commit dcb234a

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Fun.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,15 +971,15 @@ $outputObject = New-Object PSObject -Property $output |
971971

972972
# To add to the fun, we want our functions to take parameters
973973
$FormData = . $site.GetFunctionFormData.GetNewClosure() $request.Url $body $request.ContentType
974-
975-
$query = [Ordered]@{} + $FormData
976974

975+
$jsonData = [Ordered]@{}
977976
# If the method is POST and we can read input
978977
if ($body -and $request.ContentType -eq 'application/json') {
978+
Write-Warning $body
979979
$parsedBody = ConvertFrom-Json -InputObject $body
980980
foreach ($property in $parsedBody.psobject.properties) {
981981
if (-not $property) { continue }
982-
$query[$property.Name] = $parsedBody.($property.Name)
982+
$jsonData[$property.Name] = $parsedBody.($property.Name)
983983
}
984984
}
985985

@@ -1005,7 +1005,11 @@ $outputObject = New-Object PSObject -Property $output |
10051005
$functionParameters = [Ordered]@{}
10061006

10071007
# Go over every source of potential named parameters,
1008-
foreach ($namedParameters in $FormData, $pathParameters.BoundParameters) {
1008+
foreach ($namedParameters in
1009+
$FormData,
1010+
$jsonData,
1011+
$pathParameters.BoundParameters
1012+
) {
10091013
if (-not $namedParameters) { continue }
10101014
# walk over each parameter name in the set,
10111015
foreach ($parameterName in $namedParameters.Keys) {

0 commit comments

Comments
 (0)