@@ -29,11 +29,14 @@ object HttpProxy:
2929
3030 val routes : HttpRoutes [F ] = HttpRoutes .of {
3131 case (req : Request [F ]) =>
32- println(req)
32+ // println("in proxy")
33+ // println(req)
3334 val pathRendered = pathPrefix + req.uri.path.renderString
35+ // println(pathRendered)
3436 val host = req.headers.get[Host ].map(_.host).getOrElse(" " ) // Host set otherwise empty string
3537 val newServers = servers.filter(_.serverNames.contains(host))
36-
38+ // println(host)
39+ // println(newServers)
3740 val exact =
3841 newServers
3942 .flatMap(_.locations)
@@ -60,12 +63,13 @@ object HttpProxy:
6063 .headOption
6164 .map(_._2)
6265 }
63-
6466 proxy.fold(
6567 Response [F ](Status .NotFound ).withEntity(" No Route Found" ).pure[F ]
6668 )(
67- proxyThrough[F ](_, upstreams)
68- .flatMap(uri => client.toHttpApp(req.removeHeader[Host ].withUri(uri.addPath(pathRendered))))
69+ proxyThrough[F ](_, upstreams).flatMap {
70+ uri =>
71+ client.toHttpApp(req.removeHeader[Host ].withUri(uri.addPath(pathRendered)))
72+ }
6973 )
7074 }
7175
@@ -77,6 +81,8 @@ object HttpProxy:
7781 proxyPass : String ,
7882 upstreams : Map [String , NonEmptyList [ProxyConfig .UpstreamServer ]]
7983 ): F [Uri ] =
84+ println(s " proxypass $proxyPass" )
85+ println(upstreams)
8086 if ! proxyPass.contains(" $" ) then Uri .fromString(proxyPass).liftTo[F ]
8187 else
8288 extractVariable(proxyPass).flatMap {
@@ -90,6 +96,8 @@ object HttpProxy:
9096 )
9197 )
9298 }
99+ end if
100+ end proxyThrough
93101
94102 private def extractVariable [F [_]: ApplicativeThrow ](s : String ): F [(String , String , String )] =
95103 s.split('$' ).toList match
@@ -132,6 +140,8 @@ object HttpProxy:
132140
133141 def xForwardedMiddleware [G [_], F [_]](http : Http [G , F ]): Http [G , F ] = Kleisli {
134142 (req : Request [F ]) =>
143+ println(" in middleware" )
144+ println(req)
135145 req
136146 .remote
137147 .fold(http.run(req)) {
0 commit comments