1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Conreg Feign Macro
//!
//! This crate provides procedural macros for creating Feign-like declarative HTTP clients.
use TokenStream;
/// Feign Client Macro
///
/// Used to create declarative HTTP clients similar to Java Feign. By annotating a trait with this macro,
/// implementation code for HTTP requests is automatically generated, enabling RESTful communication between microservices.
///
/// # Parameters
///
/// - `service_id`: **Required**, the unique identifier of the service, used for service discovery and load balancing.
/// - `base_path`: *Optional*, the base path prefix that will be prepended to all request paths.
/// - `url`: *Optional*, directly specifies the base URL for requests; if set, `service_id` and `base_path` will be ignored.
///
/// # Supported HTTP Method Annotations
///
/// - [`#[get]`](macro.get.html) - GET request
/// - [`#[post]`](macro.post.html) - POST request
/// - [`#[put]`](macro.put.html) - PUT request
/// - [`#[delete]`](macro.delete.html) - DELETE request
/// - [`#[patch]`](macro.patch.html) - PATCH request
///
/// # Parameter Binding Methods
///
/// ## Path Parameters
/// Use `{param_name}` placeholders in the path. When a method parameter name matches the placeholder name, it is automatically bound.
///
/// Example: `#[get("/api/users/{id}")]`
///
/// ## Query Parameters
/// Use `query = "{param}"` to specify query parameter templates.
///
/// Example: `#[get(path = "/api/users", query = "id={id}")]`
///
/// ## Form Parameters
/// Use `form = "{param}"` to specify form data, supporting `application/x-www-form-urlencoded` and `multipart/form-data`.
///
/// Example: `#[post(path = "/api/login", form = "{loginForm}")]`
///
/// ## Body Parameter
/// Use `body = "{param}"` to specify the raw string body.
///
/// Example: `#[post(path = "/api/post", body = "{data}")]`
///
/// ## JSON Parameter
/// Use `json = "{param}"` to specify JSON data; it will be automatically serialized and `Content-Type: application/json` will be set.
///
/// Note: need serde_json
///
/// Example: `#[post(path = "/api/post", json = "{data}")]`
///
/// ## Header Parameter
/// Use `headers("Key: Value", ...)` or `headers("Key: {param}", ...)` to specify request headers, supporting both static values and dynamic parameters.
///
/// Example: `#[get(path = "/api/users", headers("Authorization: Bearer {token}", "Accept: application/json"))]`
/// GET request annotation
/// POST request annotation
/// PUT request annotation
/// DELETE request annotation
/// PATCH request annotation