Skip to content

Instantly share code, notes, and snippets.

@up1
Last active July 9, 2026 03:44
Show Gist options
  • Select an option

  • Save up1/432ca0b247fd75f2d242e6faf49eab71 to your computer and use it in GitHub Desktop.

Select an option

Save up1/432ca0b247fd75f2d242e6faf49eab71 to your computer and use it in GitHub Desktop.
HTTP Query method 101
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
}
// ทดสอบเรียกใช้ด้วย 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}]
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