File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ public function onRequest($request, $response)
155155
156156 do {
157157 if ($ this ->route ->getPath () == '' ) {
158- $ indexFile = $ this ->config ['http ' ]['domain ' ][$ this ->route ->getHost ()]['index ' ] ?? __DIR__ . ' /Views/index.html ' ;
158+ $ indexFile = $ this ->config ['http ' ]['domain ' ][$ this ->route ->getHost ()]['index ' ] ?? null ;
159159 $ response ->header ('X-Ngx-LogId ' , $ PGLog ->logId );
160160 $ httpCode = $ this ->sendFile ($ indexFile , $ request , $ response );
161161 $ PGLog ->pushLog ('http-code ' , $ httpCode );
@@ -362,6 +362,17 @@ public function genLogId($request)
362362 */
363363 public function sendFile ($ path , $ request , $ response )
364364 {
365+ if (empty ($ path )) {
366+ $ path = __DIR__ . '/Views/index.html ' ;
367+ if (!$ response ->sendfile ($ path )) {
368+ swoole_async_readfile ($ path , function ($ filename , $ content ) use ($ response ) {
369+ $ response ->end ($ content );
370+ });
371+ }
372+
373+ return Marco::SEND_FILE_200 ;
374+ }
375+
365376 $ path = realpath (urldecode ($ path ));
366377 $ root = $ this ->config ['http ' ]['domain ' ][$ this ->route ->getHost ()]['root ' ] ?? null ;
367378
You can’t perform that action at this time.
0 commit comments