Open hseeberger opened 7 years ago
Not sure what we can do about those ones. We know since a while that these kinds of usages are prone to compiler warnings but we haven't found a solution so far.
The problem applies to all magnet usages that work with empty argument lists.
Yeah too bad we can't silence it on specific cases :(
There's no way around it that I know of sadly, since the () is needed there otherwise we would not be able to have the { ...
right after it (scala would think the code block was attempting to "be" the magnet).
For this particular case we might come up with an alternative syntax which uses headerValueByType(HeaderCompanion)
and deprecate the old magnet-y one.
Hm that looks good actually indeed 👍
Yeah, get rid of all that magnetism if possible ;-)
For those on a quest for a warning free copy-paste.
Option 1, efficient but mysterious:
optionalHeaderValueByType[Host](()) {
???
}
Option 2, inspired by @jrudolph comments for future strategy:
/**
* https://github.com/akka/akka-http/issues/1095
*/
object Magnets {
val HostHeader = HeaderMagnet.fromUnitNormalHeader[Host]((): Unit)
}
optionalHeaderValueByType(Magnets.HostHeader) {
???
}
Success(akka.Done) takes care of the problem.