-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
154 lines (132 loc) · 3.56 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
declare(strict_types=1);
use Huid\HttpBin\Support;
use OpenApi\Annotations as OA;
use Hyperf\View\RenderInterface;
/**
* @OA\Info(
* version="0.0.1",
* title="httpbin api"
* )
*/
/**
* @OA\Server(
* url="{schema}://httpbin.mykeep.fun",
* description="OpenApi parameters",
* @OA\ServerVariable(
* serverVariable="schema",
* enum={"https", "http"},
* default="https"
* )
* )
*/
/**
* @OA\Tag(
* name="HTTP Methods",
* description="Testing different HTTP verbs"
* )
*/
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require_once __DIR__ . '/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| the core file mean the application begin.
| with watcher which can run debug mode.
| with exception log record middleware.
| with cors middleware.
|
|
*/
$app = require __DIR__ . '/src/Support/core.php';
$app->get('/', function (RenderInterface $render) {
return $render->render('index');
});
/**
* An Get API endpoint.
*
* @OA\Get(
* path="/get",
* description="The request's query parameters.",
* @OA\Response(response=200, description="The request's query parameters."),
* tags={"HTTP Methods"}
* )
*/
$app->get('/get', function () {
return Support\get_dict('args', 'headers', 'origin', 'url');
});
/**
* @OA\Put(
* path="/put",
* description="The request's PUT parameters.",
* @OA\Response(
* response=200,
* description="The request's PUT parameters."
* ),
* tags={"HTTP Methods"}
* )
*/
$app->put('/put', function () {
return Support\get_dict("url", "args", "form", "data", "origin", "headers", "files", "json");
});
/**
* @OA\Post (
* path="/post",
* summary="The request's POST parameters.",
* @OA\Response(
* response=200,
* description="The request's POST parameters."
* ),
* tags={"HTTP Methods"}
* )
*/
$app->post('/post', function () {
return Support\get_dict("url", "args", "form", "data", "origin", "headers", "files", "json");
});
/**
* @OA\Delete (
* path="/delete",
* description="The request's DELETE parameters.",
* @OA\Response(
* response=200,
* description="The request's DELETE parameters."
* ),
* tags={"HTTP Methods"}
* )
*/
$app->delete('/delete', function () {
return Support\get_dict("url", "args", "form", "data", "origin", "headers", "files", "json");
});
/**
* @OA\Patch (
* path="/patch",
* description="The request's PATCH parameters.",
* @OA\Response(
* response=200,
* description="The request's PATCH parameters."
* ),
* tags={"HTTP Methods"}
* )
*/
$app->patch('/patch', function () {
return Support\get_dict("url", "args", "form", "data", "origin", "headers", "files", "json");
});
/**
* render openapi.yaml for swagger ui
*/
$app->get('/openapi', function (Hyperf\HttpServer\Contract\ResponseInterface $render) {
return $render->raw(file_get_contents('./src/static/openapi.yaml'));
});
$app->run();