envoy-mobile icon indicating copy to clipboard operation
envoy-mobile copied to clipboard

Add subscript accessor to Headers

Open Augustyniak opened this issue 3 years ago • 2 comments

Add a more ergonomic way to access header values stored by Headers. This is for both iOS and Android.

The Swift implementation could look like:

subscript(name: String) -> [String]? {
  get {
    return self.container.value(forName: name)
  }
}

Augustyniak avatar Jun 28 '22 17:06 Augustyniak

Confirmed that the implementation of transcript accessor is possible in Kotlin too:

operator fun get(i: SomeType) : SomeOtherType { /* */ }

Documentation https://kotlinlang.org/docs/operator-overloading.html#indexed-access-operator

Augustyniak avatar Jul 06 '22 13:07 Augustyniak

@jpsim I am planning to add transcript operators to Headers and keeping value(forName: methods on Headers at the same time. Users will have two ways to access headers in a case-insensitive way. Let me know if you think that we should get rid of value(forName: option.

Augustyniak avatar Jul 06 '22 13:07 Augustyniak