55 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
66 < link rel ="icon " href ="/static/favicon.png " type ="image/x-icon " />
77
8- < title > Mock Server Config Viewer </ title >
8+ < title > Mock Server Config</ title >
99
1010 < script src ="/static/alpine.js " defer > </ script >
1111
@@ -153,24 +153,57 @@ <h1>Mock Server Config Viewer</h1>
153153 < label > Select HTTP Methods:</ label > < br />
154154 < div >
155155 < label
156- > < input type ="checkbox " value ="GET " x-model ="methods " /> GET</ label
156+ > < input
157+ type ="checkbox "
158+ value ="GET "
159+ name ="methods "
160+ x-model ="methods "
161+ />
162+ GET</ label
157163 > < br />
158164 < label
159- > < input type ="checkbox " value ="POST " x-model ="methods " /> POST</ label
165+ > < input
166+ type ="checkbox "
167+ value ="POST "
168+ name ="methods "
169+ x-model ="methods "
170+ />
171+ POST</ label
160172 > < br />
161173 < label
162- > < input type ="checkbox " value ="PUT " x-model ="methods " /> PUT</ label
174+ > < input
175+ type ="checkbox "
176+ value ="PUT "
177+ name ="methods "
178+ x-model ="methods "
179+ />
180+ PUT</ label
163181 > < br />
164182 < label
165- > < input type ="checkbox " value ="DELETE " x-model ="methods " />
183+ > < input
184+ type ="checkbox "
185+ value ="DELETE "
186+ name ="methods "
187+ x-model ="methods "
188+ />
166189 DELETE</ label
167190 > < br />
168191 < label
169- > < input type ="checkbox " value ="PATCH " x-model ="methods " />
192+ > < input
193+ type ="checkbox "
194+ value ="PATCH "
195+ name ="methods "
196+ x-model ="methods "
197+ />
170198 PATCH</ label
171199 > < br />
172200 < label
173- > < input type ="checkbox " value ="OPTIONS " x-model ="methods " />
201+ > < input
202+ type ="checkbox "
203+ value ="OPTIONS "
204+ name ="methods "
205+ x-model ="methods "
206+ />
174207 OPTIONS</ label
175208 >
176209 </ div >
@@ -221,6 +254,7 @@ <h2>Current Route Config</h2>
221254 < thead >
222255 < tr >
223256 < th > Endpoint</ th >
257+ < th > Methods</ th >
224258 < th > Response</ th >
225259 < th > Status</ th >
226260 </ tr >
@@ -229,6 +263,7 @@ <h2>Current Route Config</h2>
229263 {% for route_data in routes_data %}
230264 < tr >
231265 < td > {{ route_data.get('endpoint') }}</ td >
266+ < td > {{ route_data.get('methods') }}</ td >
232267 < td > {{ route_data.get('response') }}</ td >
233268 < td > {{ route_data.get('status') }}</ td >
234269 </ tr >
@@ -244,17 +279,23 @@ <h2>Current Route Config</h2>
244279 function validateJson ( ) {
245280 const form = document . getElementById ( "jsonForm" ) ;
246281 const jsonData = form . response_message . value ;
282+ const selectedMethods = [
283+ ...form . querySelectorAll ( 'input[name="methods"]:checked' ) ,
284+ ] . map ( ( cb ) => cb . value ) ;
247285
248- if ( isValid ( jsonData ) ) {
249- form . submit ( ) ;
250- } else {
286+ if ( ! isValid ( jsonData ) ) {
251287 alert ( "Invalid JSON format. Please correct it." ) ;
288+ } else if ( selectedMethods . length === 0 ) {
289+ alert ( "Please select at least one method." ) ;
290+ } else {
291+ form . submit ( ) ;
252292 }
253293 }
254294
255295 function isValid ( jsonString ) {
256296 try {
257297 JSON . parse ( jsonString ) ;
298+
258299 return true ;
259300 } catch {
260301 return false ;
0 commit comments