The objective is to replicate the convenient localhost URL shortcut feature found in HTTPie (https://httpie.io/docs/cli/url-shortcuts-for-localhost). The proposal suggests introducing an alias of the form :PORT/ to streamline localhost URLs.
Instead of requiring users to type treq GET localhost:3000/route, they can now use the shorthand treq GET :3000/route.
Expected Behavior:
Implement the :PORT/ alias for localhost URLs.
Possible Solution/Implementation
Currently the Url is stored as a single String. In RequestData entity. To facilitate the implementation of this and potential future solutions, it is recommended to replace this single string with a struct that comprehensively stores all URL information.
Url<'a> {
protocol: Option<&str>, // The default would be "http"
host: &str,
port: Option<u16>,
path: &str,
query_params: Vec<(&str, &str)>,
anchor: Option<&str>,
},
This struct should include a function (returning a Result) to parse a string into it, validating if the parameter can be constructed from this struct. This enhancement will not only accommodate the proposed alias feature but also opens the door for additional URL aliases in the future.
The objective is to replicate the convenient localhost URL shortcut feature found in HTTPie (https://httpie.io/docs/cli/url-shortcuts-for-localhost). The proposal suggests introducing an alias of the form :PORT/ to streamline localhost URLs.
Instead of requiring users to type treq GET localhost:3000/route, they can now use the shorthand treq GET :3000/route.
Expected Behavior:
Possible Solution/Implementation
Currently the Url is stored as a single String. In RequestData entity. To facilitate the implementation of this and potential future solutions, it is recommended to replace this single string with a struct that comprehensively stores all URL information.
This struct should include a function (returning a Result) to parse a string into it, validating if the parameter can be constructed from this struct. This enhancement will not only accommodate the proposed alias feature but also opens the door for additional URL aliases in the future.