Hello. Thank you. I am pasting the code. There is a line that says "//THIS LINE"
If I send a request without a "Service-ID" header, I get a null in "$this->o->header1". If I send the header with some random text, like "aaa", "$this->o->header1" turns into an empty object.
--------------------------------------------
<?php
namespace App\Controllers;
use App\Models\UsersModel;
use App\Libraries\CommonUser;
use CodeIgniter\Controller;
class ExtAppBaseController extends Controller
{
protected $helpers = [];
protected $me;
protected $o;
/**
* Constructor.
*/
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
// Do Not Edit This Line
parent::initController($request, $response, $logger);
$this->o = new \stdClass;
$this->o->code = 100;
$this->o->header1 = $this->request->getHeader("Service-ID"); // THIS LINE
}
}
-----------------
<?php namespace App\Controllers;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\RequestInterface;
use Config\Services;
class AppExt1Api extends ExtAppBaseController
{
public function processGet($section1) {
header('Content-Type: application/json');
echo json_encode( $this->o );
}
}