Spring Cloud OpenFeign: Difference between revisions
Jump to navigation
Jump to search
(21 intermediate revisions by the same user not shown) | |||
Line 34: | Line 34: | ||
</dependency> | </dependency> | ||
</dependencies> | </dependencies> | ||
</source> | |||
|- | |||
| colspan="2" | | |||
---- | |||
|- | |||
| valign="top" | | |||
<source lang="bash"> | |||
timeout 60 telnet localhost 1983 \ | |||
;printf '\n' | |||
</source> | |||
| valign="top" | | |||
<source lang="bash"> | |||
nc -w 60 localhost 1983 \ | |||
;printf '\n' | |||
</source> | </source> | ||
|} | |} | ||
==Mocking API== | |||
<source lang="bash"> | |||
mkdir -p ~/Documents/flask-playground/MockApi | |||
python3 -m venv ~/.venv/flask --prompt="Flask" | |||
source ~/.venv/flask/bin/activate | |||
pip install Flask | |||
</source> | |||
<source lang="bash"> | |||
rm rf ~/Documents/flask-playground/MockApi/*.py | |||
cat << EOF | tee ~/Documents/flask-playground/MockApi/__main__.py >/dev/null | |||
from flask import Flask, request, json, jsonify | |||
import time | |||
app = Flask(__name__) | |||
app.json.sort_keys = False | |||
companies = [{'id': 1, 'name': 'Chorke', 'concern': False}, {'id': 2, 'name': 'Academia', 'concern': True}] | |||
@app.route("/api/v1/companies") | |||
def data(): | |||
time.sleep(5) | |||
lang_code = request.args.get('lang_code') | |||
print(f'lang_code: {lang_code}!') | |||
# return json.dumps(companies) | |||
return jsonify(companies) | |||
if __name__ == "__main__": | |||
app.run(host='127.0.0.1', port=1983, debug= True) | |||
EOF | |||
python ~/Documents/flask-playground/MockApi | |||
</source> | |||
<source lang="bash"> | |||
time curl -k http://127.0.0.1:1983/api/v1/companies?lang_code=EN | |||
time curl -i http://127.0.0.1:1983/api/v1/companies?lang_code=EN | |||
time http GET 127.0.0.1:1983/api/v1/companies?lang_code=EN --pretty=colors | |||
</source> | |||
==References== | ==References== | ||
{| | {| | ||
| valign="top" | | | valign="top" | | ||
* [https://medium.com/javarevisited/simple-implementation-of-spring-cloud-openfeign-7f022630d01d | * [https://docs.spring.io/spring-cloud-openfeign/docs/3.1.3/reference/html/appendix.html OpenFeign » 3.1 » Common application properties] | ||
* [https://www.javacodemonk.com/feign-requestinterceptor-in-spring-boot-cbe5d967 | * [https://cloud.spring.io/spring-cloud-openfeign/2.1.x/single/spring-cloud-openfeign.html#spring-cloud-feign-overriding-defaults OpenFeign » 2.1 » Overriding Feign Defaults] | ||
* [https://www.baeldung.com/java-feign-file-upload | * [https://docs.spring.io/spring-cloud-openfeign/docs/3.1.3/reference/html/index.html#spring-cloud-feign-overriding-defaults OpenFeign » 3.1 » Overriding Feign Defaults] | ||
* [https://www.baeldung.com/spring-cloud-openfeign | * [https://medium.com/javarevisited/simple-implementation-of-spring-cloud-openfeign-7f022630d01d OpenFeign » Simple Implementation] | ||
* [https://spring.io | * [https://www.javacodemonk.com/feign-requestinterceptor-in-spring-boot-cbe5d967 OpenFeign » Request Interceptor] | ||
* [https://stackoverflow.com/questions/45233411/ OpenFeign » Using <code>@HeaderMap</code>] | |||
* [https://www.baeldung.com/java-feign-file-upload OpenFeign » Upload Multipart] | |||
* [https://spring.io/projects/spring-cloud-openfeign OpenFeign » Spring Cloud] | |||
* [https://www.baeldung.com/spring-cloud-openfeign OpenFeign » Introduction] | |||
* [https://docs.spring.io/spring-cloud-openfeign/docs/3.1.3/reference/html/ OpenFeign » Spring Cloud] | |||
| valign="top" | | | valign="top" | | ||
* [[ | * [https://cloud.spring.io/spring-cloud-openfeign/2.1.x/single/spring-cloud-openfeign.html#spring-cloud-feign-hystrix-fallbackk OpenFeign » 2.1 » CircuitBreaker Fallbacks] | ||
* [ | * [https://docs.spring.io/spring-cloud-openfeign/docs/3.1.3/reference/html/index.html#spring-cloud-feign-circuitbreaker-fallback OpenFeign » 3.1 » CircuitBreaker Fallbacks] | ||
* [https://stackoverflow.com/questions/40262132/ OpenFeign » Add a Request Interceptor] | |||
| valign="top" | | | valign="top" | | ||
Line 62: | Line 118: | ||
|- | |- | ||
| valign="top" | | | valign="top" | | ||
* [[Spring Exception Handling]] | |||
* [[Spring Security]] | |||
* [[Apache Camel]] | |||
* [[Netflix Eureka]] | |||
* [[HTTP Security]] | |||
* [[Java Lambda]] | |||
* [[Camunda]] | |||
* [[Jasypt]] | |||
* [[Redis]] | |||
* [[Java]] | |||
| valign="top" | | | valign="top" | | ||
* [[JSON Schema Validation]] | |||
* [[Logback]] | |||
* [[WinSW]] | |||
* [[Log4j2]] | |||
* [[Spring]] | |||
* [[Flask]] | |||
| valign="top" | | | valign="top" | | ||
|} | |} |
Latest revision as of 02:27, 13 February 2024
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--
others dependencies
-->
</dependencies>
</dependencyManagement>
|
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
</dependencies>
|
| |
timeout 60 telnet localhost 1983 \
;printf '\n'
|
nc -w 60 localhost 1983 \
;printf '\n'
|
Mocking API
mkdir -p ~/Documents/flask-playground/MockApi
python3 -m venv ~/.venv/flask --prompt="Flask"
source ~/.venv/flask/bin/activate
pip install Flask
rm rf ~/Documents/flask-playground/MockApi/*.py
cat << EOF | tee ~/Documents/flask-playground/MockApi/__main__.py >/dev/null
from flask import Flask, request, json, jsonify
import time
app = Flask(__name__)
app.json.sort_keys = False
companies = [{'id': 1, 'name': 'Chorke', 'concern': False}, {'id': 2, 'name': 'Academia', 'concern': True}]
@app.route("/api/v1/companies")
def data():
time.sleep(5)
lang_code = request.args.get('lang_code')
print(f'lang_code: {lang_code}!')
# return json.dumps(companies)
return jsonify(companies)
if __name__ == "__main__":
app.run(host='127.0.0.1', port=1983, debug= True)
EOF
python ~/Documents/flask-playground/MockApi
time curl -k http://127.0.0.1:1983/api/v1/companies?lang_code=EN
time curl -i http://127.0.0.1:1983/api/v1/companies?lang_code=EN
time http GET 127.0.0.1:1983/api/v1/companies?lang_code=EN --pretty=colors