1
1
package com .http4s .rho .swagger .demo
2
2
3
- import cats .effect .{Blocker , ContextShift , IO }
3
+ import cats .effect .{IO }
4
4
import org .http4s .dsl .io ._
5
5
import org .http4s .rho .RhoRoutes
6
6
import org .http4s .{HttpRoutes , Request , Response , StaticFile }
@@ -11,27 +11,26 @@ object StaticContentService {
11
11
/** Routes for getting static resources. These might be served more efficiently by apache2 or nginx,
12
12
* but its nice to keep it self contained.
13
13
*/
14
- def routes ( blocker : Blocker )( implicit cs : ContextShift [ IO ]) : HttpRoutes [IO ] = new RhoRoutes [IO ] {
14
+ def routes : HttpRoutes [IO ] = new RhoRoutes [IO ] {
15
15
// Swagger User Interface
16
16
GET / " css" / * |>> { (req : Request [IO ], _ : List [String ]) =>
17
- fetchResource(swaggerUiDir + req.pathInfo, req, blocker )
17
+ fetchResource(swaggerUiDir + req.pathInfo, req)
18
18
}
19
19
GET / " images" / * |>> { (req : Request [IO ], _ : List [String ]) =>
20
- fetchResource(swaggerUiDir + req.pathInfo, req, blocker )
20
+ fetchResource(swaggerUiDir + req.pathInfo, req)
21
21
}
22
22
GET / " lib" / * |>> { (req : Request [IO ], _ : List [String ]) =>
23
- fetchResource(swaggerUiDir + req.pathInfo, req, blocker )
23
+ fetchResource(swaggerUiDir + req.pathInfo, req)
24
24
}
25
25
GET / " swagger-ui" |>> { req : Request [IO ] =>
26
- fetchResource(swaggerUiDir + " /index.html" , req, blocker )
26
+ fetchResource(swaggerUiDir + " /index.html" , req)
27
27
}
28
28
GET / " swagger-ui.js" |>> { req : Request [IO ] =>
29
- fetchResource(swaggerUiDir + " /swagger-ui.min.js" , req, blocker )
29
+ fetchResource(swaggerUiDir + " /swagger-ui.min.js" , req)
30
30
}
31
31
}.toRoutes()
32
32
33
- private def fetchResource (path : String , req : Request [IO ], blocker : Blocker )(implicit
34
- cs : ContextShift [IO ]): IO [Response [IO ]] =
35
- StaticFile .fromResource(path, blocker, Some (req)).getOrElseF(NotFound ())
33
+ private def fetchResource (path : String , req : Request [IO ]): IO [Response [IO ]] =
34
+ StaticFile .fromResource(path, Some (req)).getOrElseF(NotFound ())
36
35
37
36
}
0 commit comments