Open cqlia opened 11 months ago
Tested with the latest zio-http version (3.0.0-RC9), and seems to work correctly.
val routes: Routes[Any, Response] = Routes(
Method.GET / Root / "test" -> Handler
.fromResource("sample file.txt")
.mapError(_ => Response.status(Status.NotFound)),
)
curl -vi -X GET http://localhost:8080/test
> GET / HTTP/1.1
> Host: localhost:9090
> User-Agent: curl/8.6.0
> Accept: */*
>
< HTTP/1.1 200 OK
Could the leading slash in the resource name be the problem ?
Describe the bug Resource related methods such as
Handler.getResourceAsFile
fail when special URL characters (like spaces) are used in the resource's path.To Reproduce Steps to reproduce the behaviour:
Handler.fromResource("/resource with spaces")
404 ZIO HTTP Resource /resource with spaces not found
)Expected behaviour The resource should be loaded and sent as the response.