@@ -83,10 +83,10 @@ public function usingRedis(): void
8383 /**
8484 * Start the WebSocket server.
8585 */
86- public function startServer (string $ host = '0.0.0.0 ' , string $ port = '8080 ' , int $ maxRequestSize = 10_000 ): void
86+ public function startServer (string $ host = '0.0.0.0 ' , string $ port = '8080 ' , string $ path = '' , int $ maxRequestSize = 10_000 ): void
8787 {
8888 $ this ->resetFiber ();
89- $ this ->server = Factory::make ($ host , $ port , maxRequestSize: $ maxRequestSize , loop: $ this ->loop );
89+ $ this ->server = Factory::make ($ host , $ port , $ path , maxRequestSize: $ maxRequestSize , loop: $ this ->loop );
9090 }
9191
9292 /**
@@ -132,12 +132,12 @@ public function triggerEvent(string $channel, string $event, array $data = []):
132132 /**
133133 * Send a request to the server.
134134 */
135- public function request (string $ path , string $ method = 'GET ' , mixed $ data = '' , string $ host = '0.0.0.0 ' , string $ port = '8080 ' , string $ appId = '123456 ' ): PromiseInterface
135+ public function request (string $ path , string $ method = 'GET ' , mixed $ data = '' , string $ host = '0.0.0.0 ' , string $ port = '8080 ' , string $ pathPrefix = '' , string $ appId = '123456 ' ): PromiseInterface
136136 {
137137 return (new Browser ($ this ->loop ))
138138 ->request (
139139 $ method ,
140- "http:// {$ host }: {$ port }/apps/ {$ appId }/ {$ path }" ,
140+ "http:// {$ host }: {$ port }{ $ pathPrefix } /apps/ {$ appId }/ {$ path }" ,
141141 [],
142142 ($ data ) ? json_encode ($ data ) : ''
143143 );
@@ -160,7 +160,7 @@ public function requestWithoutAppId(string $path, string $method = 'GET', mixed
160160 /**
161161 * Send a signed request to the server.
162162 */
163- public function signedRequest (string $ path , string $ method = 'GET ' , mixed $ data = '' , string $ host = '0.0.0.0 ' , string $ port = '8080 ' , string $ appId = '123456 ' , string $ key = 'reverb-key ' , string $ secret = 'reverb-secret ' ): PromiseInterface
163+ public function signedRequest (string $ path , string $ method = 'GET ' , mixed $ data = '' , string $ host = '0.0.0.0 ' , string $ port = '8080 ' , string $ pathPrefix = '' , string $ appId = '123456 ' , string $ key = 'reverb-key ' , string $ secret = 'reverb-secret ' ): PromiseInterface
164164 {
165165 $ timestamp = time ();
166166
@@ -179,25 +179,25 @@ public function signedRequest(string $path, string $method = 'GET', mixed $data
179179 $ query .= "&body_md5= {$ hash }" ;
180180 }
181181
182- $ string = "{$ method }\n/apps/ {$ appId }/ {$ path }\n$ query " ;
182+ $ string = "{$ method }\n{ $ pathPrefix } /apps/ {$ appId }/ {$ path }\n$ query " ;
183183 $ signature = hash_hmac ('sha256 ' , $ string , $ secret );
184184
185- return $ this ->request ("{$ path }? {$ query }&auth_signature= {$ signature }" , $ method , $ data , $ host , $ port , $ appId );
185+ return $ this ->request ("{$ path }? {$ query }&auth_signature= {$ signature }" , $ method , $ data , $ host , $ port , $ pathPrefix , $ appId );
186186 }
187187
188188 /**
189189 * Send a POST request to the server.
190190 */
191- public function postRequest (string $ path , ?array $ data = [], string $ host = '0.0.0.0 ' , string $ port = '8080 ' , string $ appId = '123456 ' ): PromiseInterface
191+ public function postRequest (string $ path , ?array $ data = [], string $ host = '0.0.0.0 ' , string $ port = '8080 ' , string $ pathPrefix = '' , string $ appId = '123456 ' ): PromiseInterface
192192 {
193- return $ this ->request ($ path , 'POST ' , $ data , $ host , $ port , $ appId );
193+ return $ this ->request ($ path , 'POST ' , $ data , $ host , $ port , $ pathPrefix , $ appId );
194194 }
195195
196196 /**
197197 * Send a signed POST request to the server.
198198 */
199- public function signedPostRequest (string $ path , ?array $ data = [], string $ host = '0.0.0.0 ' , string $ port = '8080 ' , string $ appId = '123456 ' , $ key = 'reverb-key ' , $ secret = 'reverb-secret ' ): PromiseInterface
199+ public function signedPostRequest (string $ path , ?array $ data = [], string $ host = '0.0.0.0 ' , string $ port = '8080 ' , string $ pathPrefix = '' , string $ appId = '123456 ' , $ key = 'reverb-key ' , $ secret = 'reverb-secret ' ): PromiseInterface
200200 {
201- return $ this ->signedRequest ($ path , 'POST ' , $ data , $ host , $ port , $ appId , $ key , $ secret );
201+ return $ this ->signedRequest ($ path , 'POST ' , $ data , $ host , $ port , $ pathPrefix , $ appId , $ key , $ secret );
202202 }
203203}
0 commit comments