mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
28 lines
876 B
PHP
28 lines
876 B
PHP
<?php
|
|
|
|
namespace App\Client\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use GuzzleHttp\Psr7\Response;
|
|
use function GuzzleHttp\Psr7\str;
|
|
use Illuminate\Http\Request;
|
|
use Ratchet\ConnectionInterface;
|
|
|
|
class CreateTunnelController extends Controller
|
|
{
|
|
protected $keepConnectionOpen = true;
|
|
|
|
public function handle(Request $request, ConnectionInterface $httpConnection)
|
|
{
|
|
app('expose.client')
|
|
->connectToServer($request->get('url'), $request->get('subdomain', ''), config('expose.auth_token'))
|
|
->then(function ($data) use ($httpConnection) {
|
|
$httpConnection->send(respond_json($data));
|
|
$httpConnection->close();
|
|
}, function () use ($httpConnection) {
|
|
$httpConnection->send(str(new Response(500)));
|
|
$httpConnection->close();
|
|
});
|
|
}
|
|
}
|