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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! This module contains utility functions for generating HTTP responses that
//! are commonly used in web applications. These functions simplify the process
//! of creating responses with various data types.
//!
//! # Example:
//!
//! This example illustrates how to construct a JSON-formatted response using a
//! Rust struct.
//!
//! ```rust
//! use loco_rs::{controller::format, Result};
//! use axum::Json;
//!
//! pub struct Health {
//! pub ok: bool,
//! }
//!
//! async fn ping() -> Result<Json<Health>> {
//! format::json(Health { ok: true })
//! }
//! ```
use ;
use crateResult;
/// Returns an empty response.
///
/// # Example:
///
/// This example illustrates how to return an empty response.
/// ```rust
/// use loco_rs::{controller::format, Result};
///
/// async fn endpoint() -> Result<()> {
/// format::empty()
/// }
/// ```
///
/// # Errors
///
/// Currently this function did't return any error. this is for feature
/// functionality
/// Returns a response containing the provided text.
///
/// # Example:
///
/// This example illustrates how to return an text response.
/// ```rust
/// use loco_rs::{controller::format, Result};
///
/// async fn endpoint() -> Result<String> {
/// format::text("MESSAGE-RESPONSE")
/// }
/// ```
///
/// # Errors
///
/// Currently this function did't return any error. this is for feature
/// functionality
/// Returns a JSON response containing the provided data.
///
/// # Example:
///
/// This example illustrates how to construct a JSON-formatted response using a
/// Rust struct.
///
/// ```rust
/// use loco_rs::{
/// controller::format,
/// Result,
/// };
/// use axum::Json;
///
/// pub struct Health {
/// pub ok: bool,
/// }
///
/// async fn endpoint() -> Result<Json<Health>> {
/// format::json(Health { ok: true })
/// }
/// ```
///
/// # Errors
///
/// Currently this function did't return any error. this is for feature
/// functionality
/// Returns an HTML response
///
/// # Example:
///
/// ```rust
/// use loco_rs::{
/// controller::format,
/// Result,
/// };
/// use axum::response::Html;
///
/// async fn endpoint() -> Result<Html<String>> {
/// format::html("hello, world")
/// }
/// ```
///
/// # Errors
///
/// Currently this function did't return any error. this is for feature
/// functionality