Skip to content

Commit

Permalink
feat: init route for the bot API with config and env #1
Browse files Browse the repository at this point in the history
  • Loading branch information
pxthinh committed Jul 20, 2024
1 parent 8d621ae commit 299ad00
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config/blog-api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$routePrefix = env('BLOG_API_ROUTE_PREFIX', 'api');

return [
'defaults' => [
/* Set route prefix for the blog API */
'route_prefix' => $routePrefix,
],
];
24 changes: 24 additions & 0 deletions routes/blog-api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Blog API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register bot routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Enjoy building your API!
|
*/

$routePrefix = config('blog-api.defaults.route_prefix');

Route::prefix($routePrefix)->name("$routePrefix.")->group(function () {
Route::get('/posts', function () {
return response()->json([
'message' => 'Hello from the blog API!',
]);
});
});

0 comments on commit 299ad00

Please sign in to comment.