pub unsafe fn add_to_ngx_table(
table: *mut ngx_table_elt_s,
pool: *mut ngx_pool_s,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
) -> Option<()>
Expand description
Add a key-value pair to an nginx table entry (ngx_table_elt_t
) in the given nginx memory pool.
§Arguments
table
- A pointer to the nginx table entry (ngx_table_elt_t
) to modify.pool
- A pointer to the nginx memory pool (ngx_pool_t
) for memory allocation.key
- The key string to add to the table entry.value
- The value string to add to the table entry.
§Safety
This function is marked as unsafe because it involves raw pointer manipulation and direct memory allocation using str_to_uchar
.
§Returns
An Option<()>
representing the result of the operation. Some(())
indicates success, while None
indicates a null table pointer.
§Example
// Obtain a pointer to the nginx table entry
let table: *mut ngx_table_elt_t = ngx_list_push(headers).cast();
assert!(!table.is_null());
let key: &str = "key"; // The key to add
let value: &str = "value"; // The value to add
let result = add_to_ngx_table(table, pool, key, value);