# Testing with http4s

**URL:** <https://softwaremill.community/t/testing-with-http4s/326>\
**Category:** tapir\
**Created:** [November 22, 2023, 10:51pm UTC](https://softwaremill.community/t/testing-with-http4s/326 "2023-11-22T22:51:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elyphas](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/elyphas/32/208_2.png) [@elyphas](https://softwaremill.community/u/elyphas)\
**Post date:** [November 22, 2023, 10:51pm UTC](https://softwaremill.community/t/testing-with-http4s/326/1 "2023-11-22T22:51:33Z")

</div>

How can I make this code works with http4s ?

```scala
  def backend[I, O](route:
              ServerEndpoint[Any, scala.concurrent.Future] {
                    type SECURITY_INPUT = Unit;
                    type PRINCIPAL = Unit;
                    type INPUT = I;
                    type ERROR_OUTPUT = String;
                    type OUTPUT = O
              }

             ) =
                TapirStubInterpreter(SttpBackendStub.asynchronousFuture)
                            .whenServerEndpoint(route)
                            .thenRunLogic()
                            .backend()

```

problem is with Future, but I don´t know how to change de Effect

---

<div class="post-metadata">

**Author:** ![adamw](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/adamw/32/28_2.png) [@adamw](https://softwaremill.community/u/adamw)\
**Post date:** [November 23, 2023, 9:25am UTC](https://softwaremill.community/t/testing-with-http4s/326/2 "2023-11-23T09:25:24Z")

</div>

I’d probably need a larger snippet, but I think this should work, as long as your `route` already uses `cats.effect.IO` to implement the server logic:

```auto
def backend[I, O](route: ServerEndpoint[Any, IO]) =
  TapirStubInterpreter(SttpBackendStub(new CatsMonadError[IO]()))
                            .whenServerEndpoint(route)
                            .thenRunLogic()
                            .backend()

```

Also, maybe an example project generated using [https://adopt-tapir.softwaremill.com](https://adopt-tapir.softwaremill.com) will be helpful to understand how to implement a sample endpoint.

---

<div class="post-metadata">

**Author:** ![elyphas](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/elyphas/32/208_2.png) [@elyphas](https://softwaremill.community/u/elyphas)\
**Post date:** [November 24, 2023, 2:18am UTC](https://softwaremill.community/t/testing-with-http4s/326/3 "2023-11-24T02:18:03Z")

</div>

thank you

problem solved!
