You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Query parameters are an essential part of API development in Lilya, allowing you to extract dynamic
4
-
values from the **query string** of an HTTP request. This guide explains what query parameters are,
5
-
why and when to use them, and how Lilya makes it simple and elegant to declare and inject them into your
6
-
endpoint logic.
3
+
Lilya supports **Query**, **Header**, and **Cookie** parameters to cleanly and declaratively extract data
4
+
from HTTP requests.
5
+
6
+
1.**What** each parameter type is
7
+
2.**Why** and **when** to use them
8
+
3.**Benefits** of Lilya’s parameter system
9
+
4.**How** to declare and inject them
7
10
8
11
---
9
12
10
-
## What Are Query Parameters?
13
+
## What Are Request Parameters?
11
14
12
-
Query parameters are key-value pairs passed at the end of a URL after the `?` symbol.
13
-
They are used to filter, search, paginate, or otherwise customize the data returned by an API.
15
+
***Query Parameters**: Key‑value pairs in the URL after `?`, used for filtering, searching, pagination, and optional flags.
16
+
***Header Parameters**: Metadata in HTTP headers (like `Authorization`, `X‑API‑TOKEN`), used for authentication, content negotiation, and custom flags.
17
+
***Cookie Parameters**: Key‑value pairs stored in cookies, used for sessions, CSRF tokens, user preferences, and stateful data.
14
18
15
-
For example:
19
+
---
16
20
17
-
```
21
+
## ✅ Why Use Them?
18
22
19
-
GET /items?category=books\&limit=10
23
+
***Separation of concerns**: Clearly distinguish URL modifiers (query) from metadata (headers) and state (cookies).
24
+
***Type safety**: Lilya casts and validates values automatically.
25
+
***Declarative design**: Declare parameters in your function signature, not inside your handler code.
26
+
***Consistency**: Uniform API for all parameter types with `required`, `default`, `alias`/`value`, and `cast` options.
20
27
21
-
````
28
+
---
22
29
23
-
Here, `category` and `limit` are query parameters.
30
+
## Benefits of Lilya’s Parameter System
31
+
32
+
***Clean signatures**: No manual extraction from `request`; Lilya handles it.
0 commit comments