I wrote a workaround.
public static function fromServerlessConfig(array $serverlessConfig): self
{
$routes = [];
foreach ($serverlessConfig['functions'] as $function) {
$pattern = $function['events'][0]['httpApi'] ?? null;
if (! $pattern) continue;
// Added if block
if (is_array($pattern) && $pattern['method'] && $pattern['path']) {
$pattern = "${pattern['method']} ${pattern['path']}";
}
$routes[$pattern] = $function['handler'];
}
return new self($routes);
}
dev-server/src/Router.php
Lines 25 to 34 in b66cf41
httpApiallowed "Mapping", butfromServerlessConfigmethod accepts only string.see: https://www.serverless.com/framework/docs/providers/aws/events/http-api#event-definition
I wrote a workaround.