# Does Tapir support matrix parameters like http4s' MatrixVar?

**URL:** <https://softwaremill.community/t/does-tapir-support-matrix-parameters-like-http4s-matrixvar/264>\
**Category:** tapir\
**Created:** [August 8, 2023, 9:48am UTC](https://softwaremill.community/t/does-tapir-support-matrix-parameters-like-http4s-matrixvar/264 "2023-08-08T09:48:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Denis\_N](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_N](https://softwaremill.community/u/Denis_N)\
**Post date:** [August 8, 2023, 9:48am UTC](https://softwaremill.community/t/does-tapir-support-matrix-parameters-like-http4s-matrixvar/264/1 "2023-08-08T09:48:28Z")

</div>

This one [https://http4s.org/v0.21/api/org/http4s/dsl/impl/MatrixVar.html](https://http4s.org/v0.21/api/org/http4s/dsl/impl/MatrixVar.html) ?

---

<div class="post-metadata">

**Author:** ![kciesielski](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/kciesielski/32/133_2.png) [@kciesielski](https://softwaremill.community/u/kciesielski)\
**Post date:** [August 8, 2023, 1:05pm UTC](https://softwaremill.community/t/does-tapir-support-matrix-parameters-like-http4s-matrixvar/264/2 "2023-08-08T13:05:14Z")

</div>

There’s no support for matrix parameters at the moment. Could you tell us a little bit more about your use case? I can’t see a significant advantage of using them over query parameters.

---

<div class="post-metadata">

**Author:** ![Denis\_N](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@Denis\_N](https://softwaremill.community/u/Denis_N)\
**Post date:** [August 8, 2023, 1:28pm UTC](https://softwaremill.community/t/does-tapir-support-matrix-parameters-like-http4s-matrixvar/264/3 "2023-08-08T13:28:25Z")

</div>

I believe it could be used inside the URL instead of the end. Something like that:

```auto
query parameters:
localhost/api/logs/<appId>/short?from=<from>&to=<to>

matrix parameters:
localhost/api/logs/<appId>;from=<from>;to=<to>/short

```

Allowing to place all variable part of the request in one place

---

<div class="post-metadata">

**Author:** ![kciesielski](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/kciesielski/32/133_2.png) [@kciesielski](https://softwaremill.community/u/kciesielski)\
**Post date:** [August 9, 2023, 1:43pm UTC](https://softwaremill.community/t/does-tapir-support-matrix-parameters-like-http4s-matrixvar/264/4 "2023-08-09T13:43:23Z")

</div>

Looks like a neat improvement, but apparently is not widely supported among web servers. I think this makes it not very suitable for a general support in Tapir.

---

<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:** [August 16, 2023, 1:32pm UTC](https://softwaremill.community/t/does-tapir-support-matrix-parameters-like-http4s-matrixvar/264/5 "2023-08-16T13:32:35Z")

</div>

Just to add, I think it should be fairly easy to add support for matrix parametrs yourself. You can just map over a `path` input:

```auto
val myMatrixInput: EndpointInput[(String, Map[String, String])] =
  path[String]("matrixtest").map { v =>
    val components = v.split(";")
    (components.head, toMap(components.tail))
  } { case (name, values) =>
    s"$name;${toString(values)}"
  }

```
