Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it don't work with quickstart, it return 404 not found, my route not correct ? #33

Open
weishuiliang opened this issue Jun 23, 2022 · 1 comment

Comments

@weishuiliang
Copy link

weishuiliang commented Jun 23, 2022

class TennisProcedure extends Procedure
{
    /**
     * The name of the procedure that will be
     * displayed and taken into account in the search
     *
     * @var string
     */
    public static string $name = 'tennis';

    /**
     * Execute the procedure.
     *
     * @param Request $request
     *
     * @return array|string|integer
     */
    public function ping(Request $request)
    {
        return "pong";
    }
}

and my route in api.php

Route::rpc('/v1/endpoint', [TennisProcedure::class])->name('rpc.endpoint');

and my request:

request url:
http://127.0.0.1:8006/api/v1/endpoint

request  body
{
    "jsonrpc": "2.0",
    "method": "tennis@ping",
    "id": 1
}
@tabuna
Copy link
Member

tabuna commented Jul 2, 2022

Hi @weishuiliang I checked and my new installation works well with the example you gave. Is it possible that you put the route declaration in the sanctum group and pass it without its key?

My routes file looks like this:

<?php

use Illuminate\Support\Facades\Route;
use App\Http\Procedures\TennisProcedure;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::rpc('/v1/endpoint', [TennisProcedure::class])->name('rpc.endpoint');

Checked out curl and tinker

\Illuminate\Support\Facades\Http::withBody('{"jsonrpc":"2.0","method":"tennis@ping","id":1}', 'application/json')->post('http://127.0.0.1:8000/api/v1/endpoint')->json();

Could you give more information on how to reproduce the problem? As well as the output of all registered routes (command output) artisan route:list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants