kevin-mitchell / alexa-app

Set of classes to make creating Amazon Alexa Skills Kit (ASK) applications easier with Laravel and Lumen
MIT License
97 stars 47 forks source link

My Alexa Routes are not found (Laravel) #44

Closed luebbert42 closed 6 years ago

luebbert42 commented 6 years ago

I am trying to get a "hello world" up and running

in web.php I have included: \AlexaRoute::launch('/your-app-uri', 'App\Http\Controllers\AnyController@anyMethod');

And created AnyController and anyMethod.

When I launch /your-app-uri I am getting a 404. Same when I post something against this URL using Postman. artisan route:list does not show your-app-uri as valid url.

Is this supposed to be like this? Did I miss anything to get the AlexaRouter working?

S43534 commented 6 years ago

Maybe https://github.com/develpr/alexa-app/pull/41/commits/9423ec3e79ddcc239eebe6311110f90b3e48d9b4?

Sebastian

vrajroham commented 6 years ago

@luebbert42 Try registering following middleware and see the stacktrace in logs. Let us know what is in stacktrace. Here you can verify your each request and it's parameters.

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Log;

class LogAfterRequest
{
    public function handle($request, Closure $next)
    {
        return $next($request);
    }

    public function terminate($request, $response)
    {
        Log::info('app.request', ['request' => $request->all()]);
        // Log::info('app.response', ['response' => json_encode($response->content())]);
    }

    private function getallheaders()
    {
        if (!is_array($_SERVER)) {
            return [];
        }

        $headers = [];
        foreach ($_SERVER as $name => $value) {
            if (substr($name, 0, 5) == 'HTTP_') {
                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
            }
        }

        return $headers;
    }
}
luebbert42 commented 6 years ago

issue = bogus

Explanation: The lib seems to return 404 if the request is not valid (I kind of expected another status code in this case).

I wanted to do a quick smoke test if I configured everything correctly and sent a simple "foo=bar" post request via Postman.

To do a valid smoke test I captured the alexa request using requestb.in and posted the JSON as raw request to my url using Postman. This worked.

Thanks for your support, guys, anyway :-)