Newer
Older
miracle-tv-backend / src / main / scala / sangria / Util.scala
@Илья Панфёров Илья Панфёров on 19 Jul 516 bytes feat: initial commit
package sangria.http.pekko

import org.apache.pekko.http.scaladsl.model.MediaType
import org.apache.pekko.http.scaladsl.model.headers.Accept
import org.apache.pekko.http.scaladsl.server.Directive0
import org.apache.pekko.http.scaladsl.server.Directives.{ headerValuePF, pass }

object Util {
  def explicitlyAccepts(mediaType: MediaType): Directive0 =
    headerValuePF {
      case Accept(ranges) if ranges.exists(range => !range.isWildcard && range.matches(mediaType)) =>
        ranges
    }.flatMap(_ => pass)
}