Skip to content

Commit 349ba47

Browse files
committed
Pass search address as part of path, not a query parameter
1 parent 49211b9 commit 349ba47

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ project/plugins/project/
5555
.scala_dependencies
5656
.worksheet
5757
scalastyle-config.xml
58+
.idea/

addresspoints/src/main/scala/addresspoints/api/Service.scala

+10-10
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ trait Service extends JsonProtocol with Geocode {
5151
pathPrefix("addresses") {
5252

5353
path("points") {
54-
get {
54+
post {
5555
compressResponseIfRequested() {
56-
parameter('search.as[String]) { address =>
57-
geocodePoint(address)
56+
entity(as[String]) { json =>
57+
val addressInput = json.parseJson.convertTo[AddressInput]
58+
geocodePoint(addressInput.address)
5859
}
5960
}
60-
} ~
61-
post {
61+
}
62+
} ~
63+
path("points" / Segment) { address =>
64+
get {
6265
compressResponseIfRequested() {
63-
entity(as[String]) { json =>
64-
val addressInput = json.parseJson.convertTo[AddressInput]
65-
geocodePoint(addressInput.address)
66-
}
66+
geocodePoint(address)
6767
}
6868
}
69-
}
69+
}
7070
}
7171
}
7272

addresspoints/src/test/scala/AddressPointServiceSpec.scala

+7
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ class AddressPointServiceSpec extends FlatSpec with MustMatchers with ScalatestR
7070
val f = responseAs[Feature]
7171
f mustBe getPointFeature
7272
}
73+
val a = "1311+30th+St+NW+Washington+DC+20007"
74+
Get("/addresses/points/" + a) ~> routes ~> check {
75+
status mustBe OK
76+
contentType.mediaType mustBe `application/json`
77+
val f = responseAs[Feature]
78+
f mustBe getPointFeature
79+
}
7380
}
7481

7582
}

0 commit comments

Comments
 (0)