Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbero90 committed Sep 10, 2024
1 parent 577edd2 commit e9200f7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

LazyJsonPages::from($source)
->onRequest(fn (RequestInterface $request) => ...)
->onResponse(fn (ResponseInterface $response, RequestInterface $request) => ...);
->onRequest(fn(RequestInterface $request) => ...)
->onResponse(fn(ResponseInterface $response, RequestInterface $request) => ...);
```

We can also tweak the number of allowed seconds before an API connection times out or the allowed duration of the entire HTTP request (by default they are both set to 5 seconds):
Expand All @@ -361,7 +361,7 @@ If the 3rd party API is faulty or error-prone, we can indicate how many times we
// repeat failing requests 5 times after a backoff of 1, 2, 3, 4 and 5 seconds
LazyJsonPages::from($source)
->attempts(5)
->backoff(fn (int $attempt) => $attempt * 1000);
->backoff(fn(int $attempt) => $attempt * 1000);
```

### 💢 Errors handling
Expand All @@ -373,7 +373,7 @@ use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

LazyJsonPages::from($source)
->onError(fn (Throwable $e, RequestInterface $request, ?ResponseInterface $response) => ...);
->onError(fn(Throwable $e, RequestInterface $request, ?ResponseInterface $response) => ...);
```

Any exception thrown by this package extends the `LazyJsonPagesException` class. This makes it easy to handle all exceptions in a single catch block:
Expand Down

0 comments on commit e9200f7

Please sign in to comment.