Struct haproxy_api::Http

source ·
pub struct Http<'lua>(_);
Expand description

The “Http” class contain all the HTTP manipulation functions.

Implementations§

source§

impl<'lua> Http<'lua>

source

pub fn req_get_headers(&self) -> Result<Headers<'lua>>

Returns a Headers table containing all the request headers.

source

pub fn res_get_headers(&self) -> Result<Headers<'lua>>

Returns a Headers table containing all the response headers.

source

pub fn req_add_header<V: IntoLua<'lua>>( &self, name: &str, value: V ) -> Result<()>

Appends an HTTP header field name with value in the request.

source

pub fn res_add_header<V: IntoLua<'lua>>( &self, name: &str, value: V ) -> Result<()>

Appends an HTTP header field name with value in the response.

source

pub fn req_del_header(&self, name: &str) -> Result<()>

Removes all HTTP header fields in the request by name.

source

pub fn res_del_header(&self, name: &str) -> Result<()>

Removes all HTTP header fields in the response by name.

source

pub fn req_set_header<V: IntoLua<'lua>>( &self, name: &str, value: V ) -> Result<()>

Replaces all occurrence of HTTP request header name, by only one containing the value.

source

pub fn res_set_header<V: IntoLua<'lua>>( &self, name: &str, value: V ) -> Result<()>

Replaces all occurrence of HTTP response header name, by only one containing the value.

source

pub fn req_rep_header( &self, name: &str, regex: &str, replace: &str ) -> Result<()>

Matches the regular expression in all occurrences of HTTP request header name according to regex, and replaces them with the replace argument.

The replacement value can contain back references like 1, 2, …

source

pub fn res_rep_header( &self, name: &str, regex: &str, replace: &str ) -> Result<()>

Matches the regular expression in all occurrences of HTTP response header name according to regex, and replaces them with the replace argument.

The replacement value can contain back references like 1, 2, …

source

pub fn req_set_method(&self, method: &str) -> Result<()>

Rewrites the request method with the method.

source

pub fn req_set_path(&self, path: &str) -> Result<()>

Rewrites the request path with the path.

source

pub fn req_set_query(&self, query: &str) -> Result<()>

Rewrites the request’s query string which appears after the first question mark (?) with the query.

source

pub fn req_set_uri(&self, uri: &str) -> Result<()>

Rewrites the request URI with the uri.

source

pub fn res_set_status(&self, status: u16, reason: Option<&str>) -> Result<()>

Rewrites the response status code. If no custom reason is provided, it will be generated from the status.

Trait Implementations§

source§

impl<'lua> Clone for Http<'lua>

source§

fn clone(&self) -> Http<'lua>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'lua> FromLua<'lua> for Http<'lua>

source§

fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

§

impl<'lua> !RefUnwindSafe for Http<'lua>

§

impl<'lua> !Send for Http<'lua>

§

impl<'lua> !Sync for Http<'lua>

§

impl<'lua> Unpin for Http<'lua>

§

impl<'lua> !UnwindSafe for Http<'lua>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<'lua, T> FromLuaMulti<'lua> for Twhere T: FromLua<'lua>,

source§

fn from_lua_multi(values: MultiValue<'lua>, lua: &'lua Lua) -> Result<T, Error>

Performs the conversion. Read more
source§

fn from_lua_args( args: MultiValue<'lua>, i: usize, to: Option<&str>, lua: &'lua Lua ) -> Result<T, Error>

source§

unsafe fn from_stack_multi(nvals: i32, lua: &'lua Lua) -> Result<T, Error>

source§

unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &'lua Lua ) -> Result<T, Error>

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.