#Reading input that might extend a type
8 messages · Page 1 of 1 (latest)
use reqwest crate https://docs.rs/reqwest/latest/reqwest/header/struct.HeaderMap.html ?
A set of HTTP headers
HeaderMap can store a maximum of 32,768 headers (header name / value pairs).
😄 Sorry, don't want to use any crates as this is for learning.
You won't be able to use the dot syntax for both: It's only for struct fields, and you can't add more of those at runtime.
You could, however, get both to be accessed as req.headers["headername"] if you wanted to, by putting them in a hashmap
Okay thanks! Now that I think about it, I guess my question comes down to if there is a way to offer the Header type in a library and then to extend that type with custom headers in the code that uses that library? Not at runtime, but when the library-using application code is written
(Because I now realise that supporting arbitrary headers doesn't make much sense really, since the app needs to interpret them anyways)