Skip to content

Commit

Permalink
Merge pull request #124 from hmrc/docs
Browse files Browse the repository at this point in the history
Update docs for StringContext ops
  • Loading branch information
IanMcShane authored Feb 22, 2021
2 parents eb80b3d + 85e511f commit 24b7761
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ http-verbs
==========


![](https://img.shields.io/github/v/release/hmrc/http-verbs)

http-verbs is a Scala library providing an interface to make asynchronous HTTP calls.

Expand All @@ -16,9 +17,13 @@ It encapsulates some common concerns for calling other HTTP services on the HMRC
* Auditing
* Logging
* Propagation of common headers
* Response handling, converting failure status codes into a consistent set of exceptions - allows failures to be * automatically propagated to the caller
* Response handling, converting failure status codes into a consistent set of exceptions - allows failures to be automatically propagated to the caller
* Request & Response de-serializations

## Migration

See [CHANGELOG](https://github.com/hmrc/http-verbs/blob/master/CHANGELOG.md) for changes and migrations.

## Adding to your build

In your SBT build add:
Expand All @@ -36,9 +41,12 @@ Examples can be found [here](https://github.com/hmrc/http-verbs/blob/master/http

### URLs

URLs can be supplied as either `java.net.URL` or `String`. We recommend supplying `java.net.URL` for correct escaping of query and path parameters. A [URL interpolator](https://sttp.softwaremill.com/en/latest/model/uri.html) has been implicitly provided for convenience.
URLs can be supplied as either `java.net.URL` or `String`. We recommend supplying `java.net.URL` for correct escaping of query and path parameters. A [URL interpolator](https://sttp.softwaremill.com/en/latest/model/uri.html) has been provided for convenience.


```scala
import uk.gov.hmrc.http.StringContextOps

```
url"http://localhost:8080/users/${user.id}?email=${user.email}"
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

package uk.gov.hmrc.http

trait HttpClient extends HttpGet with HttpPut with HttpPost with HttpDelete with HttpPatch
trait HttpClient extends HttpGet with HttpPut with HttpPost with HttpDelete with HttpPatch
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import java.net.URL
import sttp.model.UriInterpolator

package object http {
implicit class StringContextOps(sc: StringContext){
def url(args: Any*) : URL = UriInterpolator.interpolate(sc, args: _*).toJavaUri.toURL
implicit class StringContextOps(val sc: StringContext) extends AnyVal {
def url(args: Any*): URL =
UriInterpolator.interpolate(sc, args: _*).toJavaUri.toURL
}
}

0 comments on commit 24b7761

Please sign in to comment.