diff --git a/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Request.scala b/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Request.scala index b1ceacf8..57547d0d 100644 --- a/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Request.scala +++ b/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Request.scala @@ -9,7 +9,9 @@ import java.net.URI case class Request ( url: String, + protocol: String, domain: String, + port: Int, origPath: String, path: String, directory: String, @@ -59,7 +61,7 @@ object Request { a -> b }).toMap val path = uri.getPath - val res = Request(x, uri.getHost,path,path,"/", query,wref_null,wref_null) + val res = Request(x, uri.getScheme, uri.getHost, uri.getPort, path,path,"/", query,wref_null,wref_null) res } } diff --git a/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Route.scala b/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Route.scala index 1f14a465..7e5bb955 100644 --- a/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Route.scala +++ b/jpro-routing/core/src/main/scala/one/jpro/platform/routing/Route.scala @@ -29,6 +29,14 @@ trait Route { } } } + def domain(domain: String, route: Route): Route = and((r: Request) => { + println("request domain: " + r.domain) + if(r.domain == domain) { + route.apply(r) + } else { + null + } + }) def path(path: String, route: Route): Route = and((r: Request) => { if(r.path.startsWith(path + "/")) { val r2 = r.copy(path = r.path.drop(path.length), directory = r.resolve(path))