Skip to content

Commit

Permalink
fix: add generic addHeaders method
Browse files Browse the repository at this point in the history
  • Loading branch information
MoeQuadrat committed Oct 11, 2023
1 parent 72de9d6 commit 9ec47da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sbt.Compile
import sbt.Keys.cleanFiles
val releaseVersion = sys.env.getOrElse("TAG", "0.2.3-BETA.6")
val releaseVersion = sys.env.getOrElse("TAG", "0.4.4-Delta")
addCommandAlias("publishSmithy4Play", "smithy4play/publish")
addCommandAlias("publishLocalSmithy4Play", "smithy4play/publishLocal")
addCommandAlias("generateCoverage", "clean; coverage; test; coverageReport")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import scala.language.experimental.macros

package object smithy4play {

trait ContextRouteError extends StatusResult {
trait ContextRouteError extends StatusResult[ContextRouteError] {
def message: String
def toJson: JsValue
}
Expand All @@ -24,17 +24,17 @@ package object smithy4play {
type RouteResult[O] = EitherT[Future, ContextRouteError, O]
type ContextRoute[O] = Kleisli[RouteResult, RoutingContext, O]

trait StatusResult extends Product {
trait StatusResult[S <: StatusResult[S]] {
def status: Status
def addHeaders(headers: Map[String, String]): StatusResult
def addHeaders(headers: Map[String, String]): S
}

case class Status(headers: Map[String, String], statusCode: Int)
object Status {
implicit val format = Json.format[Status]
}

case class EndpointResult(body: Option[Array[Byte]], status: Status) extends StatusResult {
case class EndpointResult(body: Option[Array[Byte]], status: Status) extends StatusResult[EndpointResult] {
override def addHeaders(headers: Map[String, String]): EndpointResult = this.copy(
status = status.copy(
headers = status.headers ++ headers
Expand Down

0 comments on commit 9ec47da

Please sign in to comment.