我正在使用代码点火器创建REST。我下载了这个库并安装在我的应用程序中。效果很好!https://github.com/chriskacerguis/codeigniter-restserver
但我有疑问。根据这个图书馆。我有四个功能
我理解每个POST方法的功能,但我关心的是如何在REST中编写验证和其他内容。
示例:我已经创建了控制器User.php
class User extends REST_Controller {
public function __construct()
{
parent::__construct();
}
// Get multile / individual users records and perform search also.
public function index_get()
{
$this->response('get / search users', REST_Controller::HTTP_OK);
}
// User Registration / Login
public function index_post()
{
echo 'create';
}
// User Information Update
public function index_put()
{
echo 'update';
}
// User Delete
public function index_delete()
{
echo 'delete';
}
}我在邮递员中测试的方法很好。
这是我的问题。我为用户提供了以下功能。
我想除了注册表之外,其他功能都是用PUT方法发布的?在PUT / POST方法中,我是否需要写所有的验证和数据库操作,购买标识,post方法变量,使用操作如注册、登录、忘记密码等,
在管理员我想得到活跃或不活跃的用户,通过电子邮件或名称查找。这样的操作我们要写在哪里?
多亏了所有人。
发布于 2019-08-08 05:45:30
您可以在客户端进行所有基本验证,如果需要从数据库中在服务器端进行验证,则可以在rest中管理相同的验证。
用于编写服务器端验证。
class User extends REST_Controller {
public function __construct()
{
parent::__construct();
}// User Registration / Login
public function index_post()
{
$username = $this->input->post('username');
$password = $this->security->xss_clean($this->input->post("password"));
$message = $this->Login_model->check_login($username,$password);
$this->response($message);
}
}https://softwareengineering.stackexchange.com/questions/393381
复制相似问题