You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- We are making `application.yml` for this microservices.
70
+
- We are making `application.yml` for these microservices.
71
71
- If this microservice would ran in different environment, it would pick up appropriate configurations.
72
72
73
73
- Domain classes represents classes inside business logic.
74
74
75
-
- DTO classes represents REST API and are modeled using `countriesnow.space` API nesting structure. Meaning package names is from API paths and DTO class names tries to represent the given thing. I chose not make DTO classes as reusable as possible, every DTO is unique. [ReadMore](https://www.baeldung.com/java-dto-pattern#common-mistakes).
75
+
- DTO classes represents REST API and are modeled using `countriesnow.space` API nesting structure. Meaning package names is from API paths and DTO class names tries to represent the given thing. I chose not to make DTO classes as reusable as possible, every DTO is unique. [Read More](https://www.baeldung.com/java-dto-pattern#common-mistakes).
76
76
77
77
> We also want to avoid trying to use a single class for many scenarios.
78
78
79
-
- I have decided to use **ResponseEntity** in **Controller** class. [ReadMore](https://www.baeldung.com/spring-response-entity).
79
+
- I have decided to use **ResponseEntity** in **Controller** class. [Read More](https://www.baeldung.com/spring-response-entity).
80
80
81
-
> While **ResponseEntity** is very powerful, we shouldn’t overuse it. In simple cases, there are other options that satisfy our needs and they result in much cleaner code.
81
+
> While **ResponseEntity** is very powerful, we shouldn’t overuse it. In simple cases, there are other options that satisfy our needs, and they result in much cleaner code.
82
82
83
83
- We are making tests!
84
84
-**Unit Tests**:
@@ -92,36 +92,36 @@ You get bonus points if:
92
92
- ✅**WireMock**✅ for testing external APIs. In progress ♻️ **Could not get this working, for now** ♻️.
- ⚠️**Although**⚠️, this task should be approached as microservice as possible. This solution have been dockerize under one `.yml` file for sake of simplicity.
95
+
- ⚠️**Although**⚠️, this task should be approached as microservice as possible. This solution has been dockerized under one `.yml` file for sake of simplicity.
- ✅**URI Path Versioning**✅, were chosen for its popularity.
108
108
- ❌**Query Parameter Versioning**❌.
109
109
- ❌**Header Versioning**❌.
110
110
111
-
- All **API:s** are implementing **resilience** with **retrying pattern**.
111
+
- All **API’s** are implementing **resilience** with **retrying pattern**.
112
112
- Retry only **5xx** errors.
113
113
114
114
- Country letter representation "**two letters**" [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) will be used, since it was in specifications.
115
115
116
116
### Prerequisites:
117
-
-Lates java JDK is fine to run commands.
117
+
-Latest Java JDK is fine to run commands.
118
118
- Latest Docker.
119
119
120
120
# Not sure things ⚠️👀?
121
121
122
-
- I am not sure that, am i utilizing the **.subscribe** rightly. Like in this example, i don't have any of such in code directly `.subscribe(this::someFunction, this::someFunctionIfErrorHappened);`. My service is simple passing data to front end by means of **Project Reactor**. Well, yes if there would be db attached, then this would be suitable approach, but i didn't come any use for such case.
122
+
- I am not sure that, am I utilizing the **.subscribe** rightly. Like in this example, I don't have any of such in code directly `.subscribe(this::someFunction, this::someFunctionIfErrorHappened);`. My service is simple passing data to front end by means of **Project Reactor**. Well, yes if there would be db attached, then this would be suitable approach, but I didn't come any use for such case.
123
123
124
-
- Other thing is the **Subscriptions** itself, i should make SSE end point to back end and Angular app would listen this stream for new countries? Now its just service for REST api call in world of **Project Reactor**.
124
+
- Other thing is the **Subscriptions** itself, I should make SSE end point to back end and Angular app would listen this stream for new countries? Now its just service for REST API call in world of **Project Reactor**.
125
125
126
126
# How to run!
127
127
@@ -160,7 +160,7 @@ docker-compose up --build
160
160
ng serve
161
161
```
162
162
163
-
- Check console for website! Normally its `http://localhost:4200/`.
163
+
- Check console for the website! Normally its `http://localhost:4200/`.
- I came to notice when making **POST** request to the address of `https://countriesnow.space/api/v0.1/countries/population` it would work for **Postman**, but not for **Reactor Netty**.
239
239
240
-
- Tool to catch the request were **Request Catcher**, it helped me to distinguish if there were some error in the request what **Reactor Netty** was making. URL of catcher `https://test.requestcatcher.com/`. **POST** didn't work for some reason and could not get any stream of data back from **Web Client** using DTO classes.
241
-
- I noticed the only difference mainly was headers. Upper picture from **Reactor Netty** request and below it is from **Postman**, which worked. I tried to change **User-Agent** to `User-Agent: PostmanRuntime/7.42.0` in **Reactor Netty** so it would work, but my luck failed.
240
+
- Tool to catch the request was **Request Catcher**, it helped me to distinguish if there were some error in the request what **Reactor Netty** was making. URL of catcher `https://test.requestcatcher.com/`. **POST** didn't work for some reason and could not get any stream of data back from **Web Client** using DTO classes.
241
+
- I noticed the only difference mainly was in headers. Upper picture from **Reactor Netty** request and below it is from **Postman**, which worked. I tried to change **User-Agent** to `User-Agent: PostmanRuntime/7.42.0` in **Reactor Netty** so it would work, but my luck failed.
- Due to the inspections how Postman had it working with this API. It had following settings `Accept: */*`.
247
+
- Due to the inspections how Postman had it working with this API. It had the following settings `Accept: */*`.
248
248
249
-
- Luckily returning `Mono<String>` from **POST** function and setting `@Data` for DTO class which was for serving as param class. Also i changed **Reactor Netty** headers to `"Accept", MediaType.ALL_VALUE` from `"Accept", MediaType.APPLICATION_JSON_VALUE`(since API gives JSON), gave me positive surprise.
249
+
- Luckily returning `Mono<String>` from **POST** function and setting `@Data` for DTO class which was for serving as param class. Also, I changed **Reactor Netty** headers to `"Accept", MediaType.ALL_VALUE` from `"Accept", MediaType.APPLICATION_JSON_VALUE`(since API gives JSON), gave me positive surprise.
250
250
251
251
```
252
252
@Bean
@@ -273,15 +273,15 @@ public class ParamClass {
273
273
274
274
- Also, WebClient started to worked normally after right Header information `.doOnSuccess(result -> System.out.println("Response: " + result));` gave me `Response: Moved Permanently. Redirecting to /api/v0.1/countries/population/q?country=Finland`.
275
275
276
-
- All thought it was saying **redirecting**, i could not catch redirect message in network tab. Maybe it was due **Reactor Netty** needs to be configured to process these one, but for now i decided to just use this **hint** as API query and move forward with the task :)
276
+
- All thought it was saying **redirecting**, I could not catch redirect message in network tab. Maybe it was a due **Reactor Netty** needs to be configured to process these one, but for now I just decided to use this **hint** as API query and move forward with the task :)
- I came to same conclusion as last error message when making **POST** request to the address of `https://countriesnow.space/api/v0.1/countries/flag/images` it would work for **Postman**, but not for **Reactor Netty**. This time message was `"Moved Permanently. Redirecting to /api/v0.1/countries/flag/images/q?country=NG"` and i had much fun clicking eastern egg like 5 minutes :D. No redirect messages again.
284
+
- I came to same conclusion as last error message when making **POST** request to the address of `https://countriesnow.space/api/v0.1/countries/flag/images` it would work for **Postman**, but not for **Reactor Netty**. This time message was `"Moved Permanently. Redirecting to /api/v0.1/countries/flag/images/q?country=NG"` and I had much fun clicking eastern egg like 5 minutes :D. No redirect messages again.
0 commit comments