ParamMagnet should have parameterisable character set for query parameters
- Dominant language
- Scala
- Stars
- 1.4k
- Forks
- 584
- Avg merge
- 14h 33m
- Merged PRs (30d)
- 24
Description
I am implementing a HTTP server API which uses arbitrary octets in query parameters. If I try to use akka-http's high-level routing API via e.g. `parameters('binary_data) { param => ... }`, it attempts to decode the octets as UTF-8 and corrupts them. I would like them to be decoded as ISO-8859-1 instead.
As a workaround, I have used akka-http's low-level API and implemented my own variant of `ParameterDirectives.parameterMultiMap` thus:
```scala
val parameterMultiMapLatin1: Directive1[Map[String, List[String]]] = Directives.extract(
rctx => rctx.request.uri.query(charset = LATIN1).toMultiMap
)
```
This works and allows me to implement my API, but it would be much cleaner if I could specify the character set to the akka-http high-level API rather than have to hand-parse the output of `parameterMultiMapLatin1`. The problem appears to be that due to the architecture of `ParamMagnet` and its use of sealed types, I cannot subclass and replace functions to add the `charset=` parameter to the various `query()` calls it makes.
I would have been happy to implement a suitable patch for akka-http and make a pull request, but the requirement to sign the Lightbend CLA puts me right off.
Contributor guide
Research direction
Start with ParamMagnet and ParameterDirectives.parameterMultiMap, then trace the high-level routing calls to request URI query(charset = ...). Verify the existing Latin-1 workaround against the desired configurable behavior; done means query parameters can select ISO-8859-1 without hand-parsing the low-level API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100