-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
68 lines (52 loc) · 1.71 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
define("MIRESEH", true);
$serviceHeaders = [
"Content-Type" => "application/json; charset=utf-8",
"Access-Control-Allow-Origin"=> "*",
"Access-Control-Allow-Methods"=>"GET, POST, OPTIONS, PUT, DELETE",
"Allow"=>"GET, POST, OPTIONS, PUT, DELETE",
"Access-Control-Allow-Headers: sessionID, authID, Authorization, X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Allow-Request-Method",
];
require 'vendor/autoload.php';
use Mark\App;
use Workerman\Protocols\Http\Response;
use Medoo\Medoo;
use Jchook\Uuid;
$database = new Medoo([
"type" => "mysql",
"host" => "localhost",
"database" => "mireseh",
"username" => "root",
"password" => "01",
// "prefix" => ""
]);
require "utiles/number.php";
require "utiles/money.php";
require "utiles/body.php";
$api = new App('http://0.0.0.0:3003');
$api->count = 4; // process count
$api->any('/', function ($request) {
return 'Hello world!';
});
$api->get('/hello/{name}[/]', function ($request, $name) {
// https://github.com/walkor/Workerman/blob/master/Protocols/Http.php
print_r($request->uri());
print_r($request->path());
print_r($request->queryString());
print_r($request->session());
print_r($request->cookie());
print_r($request->file("name"));
print_r($request->rawHead());
print_r($request->rawBody());
$data = [
"name"=>"Hello $name!",
];
return new Response(200, ["Content-Type" => "application/json; charset=utf-8"], encode($data));
});
$api->post('/user/create', function ($request) {
return encode(['code'=>0 ,'message' => 'ok']);
});
require "routes/sign-in.php";
require "routes/verification.php";
require "routes/guest.php";
$api->start();