Skip to content

Commit 601cfa9

Browse files
authored
docs: class defined as "Ping" but endpoints trying to fetch "Pings" (#10033)
1 parent cef5cb5 commit 601cfa9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

user_guide_src/source/guides/api/first-endpoint.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Then, in **app/Config/Routing.php**, confirm auto-routing is **enabled**:
3333
3434
public bool $autoRoute = true;
3535
36-
That's all you need for CodeIgniter to automatically map your controller classes and to URIs like ``GET /api/pings`` or ``POST /api/pings``.
36+
That's all you need for CodeIgniter to automatically map your controller classes and to URIs like ``GET /api/ping`` or ``POST /api/ping``.
3737

3838
Create a Ping Controller
3939
========================
@@ -53,7 +53,7 @@ Edit the file so it looks like this:
5353
Here we:
5454

5555
- Use the :php:class:`ResponseTrait`, which already includes REST helpers such as :php:meth:`respond()` and proper status codes.
56-
- Define a ``getIndex()`` method. The ``get`` prefix means it responds to ``GET`` requests, and the ``Index`` name means it matches the base URI (``/api/pings``).
56+
- Define a ``getIndex()`` method. The ``get`` prefix means it responds to ``GET`` requests, and the ``Index`` name means it matches the base URI (``/api/ping``).
5757

5858
Test the route
5959
==============
@@ -66,8 +66,8 @@ Start the development server if it isn't running:
6666
6767
Now visit:
6868

69-
- **Browser:** ``http://localhost:8080/api/pings``
70-
- **cURL:** ``curl http://localhost:8080/api/pings``
69+
- **Browser:** ``http://localhost:8080/api/ping``
70+
- **cURL:** ``curl http://localhost:8080/api/ping``
7171

7272
Expected response:
7373

@@ -82,9 +82,9 @@ Congratulations — that's your first working JSON endpoint!
8282
Understand how it works
8383
=======================
8484

85-
When you request ``/api/pings``:
85+
When you request ``/api/ping``:
8686

87-
1. The **Improved Auto Router** finds the ``App\Controllers\Api\Pings`` class.
87+
1. The **Improved Auto Router** finds the ``App\Controllers\Api\Ping`` class.
8888
2. It detects the HTTP verb (``GET``).
8989
3. It calls the corresponding method name: ``getIndex()``.
9090
4. :php:trait:`ResponseTrait` provides helper methods to produce consistent output.
@@ -94,9 +94,9 @@ Here's how other verbs would map if you added them later:
9494
+-----------------------+--------------------------------+
9595
| HTTP Verb | Method Name |
9696
+=======================+================================+
97-
| ``GET /api/pings`` | ``getIndex()`` |
98-
| ``POST /api/pings`` | ``postIndex()`` |
99-
| ``DELETE /api/pings`` | ``deleteIndex()`` |
97+
| ``GET /api/ping`` | ``getIndex()`` |
98+
| ``POST /api/ping`` | ``postIndex()`` |
99+
| ``DELETE /api/ping`` | ``deleteIndex()`` |
100100
+-----------------------+--------------------------------+
101101

102102
Content Negotiation with the Format Class

0 commit comments

Comments
 (0)