Newer
Older
miracle-tv-backend / src / main / scala / sangria / Util.scala
@Илья Панфёров Илья Панфёров on 19 Jul 516 bytes feat: initial commit
  1. package sangria.http.pekko
  2.  
  3. import org.apache.pekko.http.scaladsl.model.MediaType
  4. import org.apache.pekko.http.scaladsl.model.headers.Accept
  5. import org.apache.pekko.http.scaladsl.server.Directive0
  6. import org.apache.pekko.http.scaladsl.server.Directives.{ headerValuePF, pass }
  7.  
  8. object Util {
  9. def explicitlyAccepts(mediaType: MediaType): Directive0 =
  10. headerValuePF {
  11. case Accept(ranges) if ranges.exists(range => !range.isWildcard && range.matches(mediaType)) =>
  12. ranges
  13. }.flatMap(_ => pass)
  14. }