Skip to content

Commit 1fe22a9

Browse files
0xJackycursoragent
andauthored
feat: allow full HTTP status codes for health checks (#1458)
* Add 401 Unauthorized to SiteHealthCheckModal status codes Co-authored-by: jacky-943572677 <[email protected]> * Checkpoint before follow-up message Co-authored-by: jacky-943572677 <[email protected]> * Refactor status code selection to use grouped options Co-authored-by: jacky-943572677 <[email protected]> * Fix: Correct apostrophe in "I'm a teapot" status Co-authored-by: jacky-943572677 <[email protected]> --------- Co-authored-by: Cursor Agent <[email protected]>
1 parent dddb867 commit 1fe22a9

File tree

1 file changed

+124
-19
lines changed

1 file changed

+124
-19
lines changed

app/src/views/dashboard/components/SiteHealthCheckModal.vue

Lines changed: 124 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,114 @@ const formData = ref<EnhancedHealthCheckConfig>({
5454
clientKey: '',
5555
})
5656
57+
interface StatusCodeOption {
58+
value: number
59+
label: string
60+
}
61+
62+
interface StatusCodeGroup {
63+
title: string
64+
options: StatusCodeOption[]
65+
}
66+
67+
function createStatusOption(code: number, description: string): StatusCodeOption {
68+
return {
69+
value: code,
70+
label: `${code} ${description}`,
71+
}
72+
}
73+
74+
const statusCodeGroups: StatusCodeGroup[] = [
75+
{
76+
title: 'Informational Responses (1xx)',
77+
options: [
78+
createStatusOption(100, 'Continue'),
79+
createStatusOption(101, 'Switching Protocols'),
80+
createStatusOption(102, 'Processing'),
81+
createStatusOption(103, 'Early Hints'),
82+
],
83+
},
84+
{
85+
title: 'Successful Responses (2xx)',
86+
options: [
87+
createStatusOption(200, 'OK'),
88+
createStatusOption(201, 'Created'),
89+
createStatusOption(202, 'Accepted'),
90+
createStatusOption(203, 'Non-Authoritative Information'),
91+
createStatusOption(204, 'No Content'),
92+
createStatusOption(205, 'Reset Content'),
93+
createStatusOption(206, 'Partial Content'),
94+
createStatusOption(207, 'Multi-Status'),
95+
createStatusOption(208, 'Already Reported'),
96+
createStatusOption(226, 'IM Used'),
97+
],
98+
},
99+
{
100+
title: 'Redirection Messages (3xx)',
101+
options: [
102+
createStatusOption(300, 'Multiple Choices'),
103+
createStatusOption(301, 'Moved Permanently'),
104+
createStatusOption(302, 'Found'),
105+
createStatusOption(303, 'See Other'),
106+
createStatusOption(304, 'Not Modified'),
107+
createStatusOption(305, 'Use Proxy'),
108+
createStatusOption(306, 'Switch Proxy (Unused)'),
109+
createStatusOption(307, 'Temporary Redirect'),
110+
createStatusOption(308, 'Permanent Redirect'),
111+
],
112+
},
113+
{
114+
title: 'Client Error Responses (4xx)',
115+
options: [
116+
createStatusOption(400, 'Bad Request'),
117+
createStatusOption(401, 'Unauthorized'),
118+
createStatusOption(402, 'Payment Required'),
119+
createStatusOption(403, 'Forbidden'),
120+
createStatusOption(404, 'Not Found'),
121+
createStatusOption(405, 'Method Not Allowed'),
122+
createStatusOption(406, 'Not Acceptable'),
123+
createStatusOption(407, 'Proxy Authentication Required'),
124+
createStatusOption(408, 'Request Timeout'),
125+
createStatusOption(409, 'Conflict'),
126+
createStatusOption(410, 'Gone'),
127+
createStatusOption(411, 'Length Required'),
128+
createStatusOption(412, 'Precondition Failed'),
129+
createStatusOption(413, 'Payload Too Large'),
130+
createStatusOption(414, 'URI Too Long'),
131+
createStatusOption(415, 'Unsupported Media Type'),
132+
createStatusOption(416, 'Range Not Satisfiable'),
133+
createStatusOption(417, 'Expectation Failed'),
134+
createStatusOption(418, 'I\'m a teapot'),
135+
createStatusOption(421, 'Misdirected Request'),
136+
createStatusOption(422, 'Unprocessable Content'),
137+
createStatusOption(423, 'Locked'),
138+
createStatusOption(424, 'Failed Dependency'),
139+
createStatusOption(425, 'Too Early'),
140+
createStatusOption(426, 'Upgrade Required'),
141+
createStatusOption(428, 'Precondition Required'),
142+
createStatusOption(429, 'Too Many Requests'),
143+
createStatusOption(431, 'Request Header Fields Too Large'),
144+
createStatusOption(451, 'Unavailable For Legal Reasons'),
145+
],
146+
},
147+
{
148+
title: 'Server Error Responses (5xx)',
149+
options: [
150+
createStatusOption(500, 'Internal Server Error'),
151+
createStatusOption(501, 'Not Implemented'),
152+
createStatusOption(502, 'Bad Gateway'),
153+
createStatusOption(503, 'Service Unavailable'),
154+
createStatusOption(504, 'Gateway Timeout'),
155+
createStatusOption(505, 'HTTP Version Not Supported'),
156+
createStatusOption(506, 'Variant Also Negotiates'),
157+
createStatusOption(507, 'Insufficient Storage'),
158+
createStatusOption(508, 'Loop Detected'),
159+
createStatusOption(510, 'Not Extended'),
160+
createStatusOption(511, 'Network Authentication Required'),
161+
],
162+
},
163+
]
164+
57165
// Load existing config when site changes
58166
watchEffect(async () => {
59167
if (props.site) {
@@ -448,27 +556,24 @@ async function handleTest() {
448556

449557
<AFormItem :label="$gettext('Expected Status Codes')">
450558
<ASelect
451-
v-model:value="formData.expectedStatus" mode="multiple" style="width: 100%"
559+
v-model:value="formData.expectedStatus"
560+
mode="multiple"
561+
style="width: 100%"
452562
placeholder="200, 201, 204..."
453563
>
454-
<ASelectOption :value="200">
455-
200 OK
456-
</ASelectOption>
457-
<ASelectOption :value="201">
458-
201 Created
459-
</ASelectOption>
460-
<ASelectOption :value="204">
461-
204 No Content
462-
</ASelectOption>
463-
<ASelectOption :value="301">
464-
301 Moved Permanently
465-
</ASelectOption>
466-
<ASelectOption :value="302">
467-
302 Found
468-
</ASelectOption>
469-
<ASelectOption :value="304">
470-
304 Not Modified
471-
</ASelectOption>
564+
<ASelectOptGroup
565+
v-for="group in statusCodeGroups"
566+
:key="group.title"
567+
:label="group.title"
568+
>
569+
<ASelectOption
570+
v-for="option in group.options"
571+
:key="option.value"
572+
:value="option.value"
573+
>
574+
{{ option.label }}
575+
</ASelectOption>
576+
</ASelectOptGroup>
472577
</ASelect>
473578
</AFormItem>
474579

0 commit comments

Comments
 (0)