Skip to content

Commit

Permalink
Feature: Support Custom statuses code (#1121)
Browse files Browse the repository at this point in the history
* support custom Status for HtppError

* support custom Status for HttpError

* updated code based on review.

* fixed tests

* Refactor: Http.Status names to Camel Case (#1128)

* changed from Capitalized Status names to Camel Case

* proper camel case usage

* Update zio-http/src/main/scala/zhttp/http/HttpError.scala

Co-authored-by: Tushar Mathur <tusharmath@gmail.com>

* fixed after conflict

* updated tests

Co-authored-by: Tushar Mathur <tusharmath@gmail.com>
  • Loading branch information
gciuloaica and tusharmath authored Mar 10, 2022
1 parent 5069856 commit 0de7b80
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion zio-http/src/main/scala/zhttp/http/HttpError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ object HttpError {

final case class BadGateway(msg: String = "Bad Gateway") extends HttpError(Status.BadGateway, msg)

final case class CustomResponseStatus(code: Int, reason: String) extends HttpError(Status.Custom(code), reason)
final case class Custom(code: Int, reason: String) extends HttpError(Status.Custom(code), reason)

}
2 changes: 1 addition & 1 deletion zio-http/src/test/scala/zhttp/http/HttpErrorSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object HttpErrorSpec extends DefaultRunnableSpec {
assert(result)(equalTo("Page not found"))
} +
test("should create custom error") {
val error = HttpError.CustomResponseStatus(451, "Unavailable for legal reasons.")
val error = HttpError.Custom(451, "Unavailable for legal reasons.")
assert(error.status)(equalTo(Status.Custom(451)))
}
}
Expand Down

0 comments on commit 0de7b80

Please sign in to comment.