Skip to content

RESTful behaviour #2122

Description

@psuplat

First of all I apologize for throwing a "help me" question here instead of on the forum, but since the registration is temporarily disabled I can't create an account to post.

I trying to understand how the HTTP verbs in routes function.

I have a route defined as such:
$routes->post('/users/create', 'Users::create');

and my controller is as follows:

<?php namespace App\Controllers;

use App\Models\UsersModel;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\Request;

class Users extends BaseController
{
    use ResponseTrait;
    
    
	public function create()
	{
            // Some code in here
            return $this->respond($data, 200);
        }
}

now, if I try to access the route with GET method I would expect to see some kind of error, probably 405 - Method not allowed. Instead the code executes and I get a 200 response.

Am I missing something obvious here?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions