-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
As part of my little rest_client
project, I'm interested in making it possible for the user to specify custom headers for a request using string tuples, like ("X-Modhash", "foobar")
.
I'm totally impressed with this typed header design, especially on the server side where you've defined a set of headers that you're willing to process.
But, I don't see a way for a client to set
a new header into the Headers
object without actually creating a new struct that implements the Header
trait and defines the name of the header as a static string (e.g. "X-Modhash"
) returned by fn header_name
.
This seems to make it impossible for a client to specify a new header at runtime without creating a new struct at compile-time.
I took a stab at using macros to do it, but my Rust knowledge hit a wall. So, I thought I'd ask.
How would you implement a custom header on the client side without requiring the user to write a ~16 line struct/impl definition for that header?
Thanks!