socketioxide icon indicating copy to clipboard operation
socketioxide copied to clipboard

Documentation on how to make custom extractors

Open sergiomeneses opened this issue 5 months ago • 2 comments

Is your feature request related to a problem? Please describe. I want to create a custom extrators for my app.

Describe the solution you'd like Add an example of a extrator that access state.

Describe alternatives you've considered Just docs

Additional context I need to create my custom extrators but i found so far the following issues:

  1. When i implement FromMessageParts (or any of these handler traits), i can't get the json_serde::Value andbytes::Bytes types (you should export these), i currently using sqlx::types::JsonValue andaxum::body::Bytes.
  2. If i need my custom extrator to access socket state, the only solution at the moment is to create the state from the current message (also for other type handlers) i.e. State::<T>::from_message_parts(s, v, p, ack_id) which returns Result<Self, StateNotFound<T>>, so i have consum the result and covert to option using ok(), and finally unwrap() the option, which is safe in my context but i think we need a better way to do this kind of extractors (axum gets the state as parameter in the from_request_parts function).
  3. Also we need a way to multiple extrator like axums does i.e `Data((one, two, three)): Data<(TypeOne, TypeTwo, TypeThree)>

sergiomeneses avatar Sep 26 '24 14:09 sergiomeneses