response()->write('index'); } /** * @Method(allow={POST}) */ function allowPostMethod() { $this->response()->write('allowPostMethod'); } /** * @ApiAuth(name="onRequestAuth1", description="onRequest-auth1") * @ApiAuth(name="onRequestAuth2", description="onRequest-auth2") * @Param(name="onRequestParam1", description="onRequest-param1") * @Param(name="onRequestParam2", description="onRequest-param2") * @param string|null $action * @return bool|null */ protected function onRequest(?string $action): ?bool { return parent::onRequest($action); // TODO: Change the autogenerated stub } function onException(\Throwable $throwable): void { if($throwable instanceof ParamValidateError){ $this->response()->write("PE-{$throwable->getValidate()->getError()->getField()}"); }else{ throw $throwable; } } /** * @Param(name="param1",required="",integer="") */ function param1() { $this->response()->write($this->request()->getRequestParam('param1')); } /** * @Api(name="param2",path="/param2") * @Param(name="param1",required="",integer="") * @Param(name="param2",required="",integer="") */ function param2() { $p1 = $this->request()->getRequestParam('param1'); $p2 = $this->request()->getRequestParam('param2'); $this->response()->write($p1 + $p2); } /** * @Param(name="param1",required="",integer="") * @Param(name="groupParamA",required="",integer="") */ function param3() { //测试与api group的合并 $p1 = $this->request()->getRequestParam('param1'); $p2 = $this->request()->getRequestParam('groupParamA'); $this->response()->write($p1 + $p2); } function paramExport1($groupParamA) { $this->response()->write($groupParamA); } /** * @Param(name="exp") */ function paramExport2($groupParamA,$exp) { $this->response()->write($exp); } /** * @Param(name="param1",required="") * @InjectParamsContext(key="data",onlyParamTag=false); */ function injectParam1() { $this->response()->write(implode("|",ContextManager::getInstance()->get('data'))); } /** * @Param(name="param1",required="") * @InjectParamsContext(key="data"); */ function injectParam2() { $this->response()->write(implode("|",ContextManager::getInstance()->get('data'))); } public function inject() { $this->response()->write($this->inject->index()); } public function injectGetString() { $this->response()->write($this->inject->getString()); } public function injectGetArray() { $this->response()->write(json_encode($this->inject->getArray())); } protected function gc() { //不调用父类重置成员属性,方便单元测试 } }