All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.edadma.apion.ResultOps.scala Maven / Gradle / Ivy

Go to download

A type-safe HTTP server framework for Scala.js that combines Express-style ergonomics with Scala's powerful type system

There is a newer version: 0.0.7
Show newest version
package io.github.edadma.apion

import scala.concurrent.Future
import org.scalajs.macrotaskexecutor.MacrotaskExecutor.Implicits.global

implicit class ResultOps(result: Future[Result]) {
  def withHeader(name: String, value: String): Future[Result] =
    result.map {
      case Complete(r) => Complete(r.copy(headers = r.headers.add(name, value)))
      case other       => other
    }

  def withHeaders(newHeaders: (String, String)*): Future[Result] =
    result.map {
      case Complete(r) => Complete(r.copy(headers = r.headers.addAll(newHeaders)))
      case other       => other
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy