io.github.edadma.apion.ResultOps.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apion_sjs1_3 Show documentation
Show all versions of apion_sjs1_3 Show documentation
A type-safe HTTP server framework for Scala.js that combines Express-style ergonomics with Scala's powerful type system
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