Last active
July 9, 2026 03:44
-
-
Save up1/432ca0b247fd75f2d242e6faf49eab71 to your computer and use it in GitHub Desktop.
HTTP Query method 101
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| QUERY /search HTTP/1.1 | |
| Host: ://demo.com | |
| Content-Type: application/json | |
| { | |
| "status": "completed", | |
| "date_range": { "start": "2026-01-01", "end": "2026-07-31" }, | |
| "sort": "DESC | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ทดสอบเรียกใช้ด้วย GET method | |
| $curl -i http://localhost:5050/search | |
| HTTP/1.1 405 Method Not Allowed | |
| Content-Length: 0 | |
| Date: Thu, 09 Jul 2026 03:40:09 GMT | |
| Server: Kestrel | |
| Allow: QUERY | |
| // ทดสอบเรียกใช้ด้วย QUERY method | |
| $curl -i -X QUERY http://localhost:5050/search | |
| HTTP/1.1 200 OK | |
| Content-Type: application/json; charset=utf-8 | |
| Date: Thu, 09 Jul 2026 03:43:49 GMT | |
| Server: Kestrel | |
| Transfer-Encoding: chunked | |
| [{"date":"2026-07-10","temperatureC":6,"summary":"Freezing","temperatureF":42},{"date":"2026-07-11","temperatureC":45,"summary":"Balmy","temperatureF":112},{"date":"2026-07-12","temperatureC":4,"summary":"Balmy","temperatureF":39},{"date":"2026-07-13","temperatureC":19,"summary":"Freezing","temperatureF":66},{"date":"2026-07-14","temperatureC":-20,"summary":"Mild","temperatureF":-3}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.MapMethods("/search",[HttpMethods.Query], () => | |
| { | |
| var forecast = Enumerable.Range(1, 5).Select(index => | |
| new WeatherForecast | |
| ( | |
| DateOnly.FromDateTime(DateTime.Now.AddDays(index)), | |
| Random.Shared.Next(-20, 55), | |
| summaries[Random.Shared.Next(summaries.Length)] | |
| )) | |
| .ToArray(); | |
| return forecast; | |
| }) | |
| .WithName("GetWeatherForecast"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment