diff options
| author | John Turner <jturner.usa@gmail.com> | 2026-03-04 23:21:56 -0500 |
|---|---|---|
| committer | John Turner <jturner.usa@gmail.com> | 2026-03-04 23:21:56 -0500 |
| commit | a933ac4a6d99deb6859a4c72761572ef55764afe (patch) | |
| tree | f2deb645317dd0f6317049408f340cf31e1b1865 /src/request.rs | |
| parent | 4a16841789604614bc495c36972236749e5f35b0 (diff) | |
| download | httpd-a933ac4a6d99deb6859a4c72761572ef55764afe.tar.gz | |
fixup
Diffstat (limited to 'src/request.rs')
| -rw-r--r-- | src/request.rs | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/request.rs b/src/request.rs index 6da46ee..1a0611f 100644 --- a/src/request.rs +++ b/src/request.rs @@ -92,6 +92,24 @@ impl Request { } } +impl UserData for Request { + fn add_fields<F: mlua::UserDataFields<Self>>(fields: &mut F) { + fields.add_field_method_get("method", |_, this| Ok(this.method().to_string())); + + fields.add_field_method_get("path", |_, this| Ok(this.path().0.clone())); + + fields.add_field_method_get("headers", |lua, this| { + let table = lua.create_table()?; + + for (key, value) in this.headers() { + table.set(key.clone(), value.clone())?; + } + + Ok(table) + }) + } +} + fn method<'a>() -> impl Parser<&'a [u8], Output = Method> { tag(b"GET".as_slice()) .map(|_| Method::Get) @@ -121,24 +139,6 @@ fn header<'a>() -> impl Parser<&'a [u8], Output = (Vec<u8>, Vec<u8>)> { key.and(value.preceded_by(tag(b": ".as_slice()))) } -impl UserData for Request { - fn add_fields<F: mlua::UserDataFields<Self>>(fields: &mut F) { - fields.add_field_method_get("method", |_, this| Ok(this.method().to_string())); - - fields.add_field_method_get("path", |_, this| Ok(this.path().0.clone())); - - fields.add_field_method_get("headers", |lua, this| { - let table = lua.create_table()?; - - for (key, value) in this.headers() { - table.set(key.clone(), value.clone())?; - } - - Ok(table) - }) - } -} - #[allow(clippy::type_complexity)] fn parse<'a>() -> impl Parser<&'a [u8], Output = ((Method, Vec<u8>), Vec<(Vec<u8>, Vec<u8>)>)> { method() |
