GithubHelp home page GithubHelp logo

error-prone-restemplate's Introduction

Error Services

This is a contrived example to show how you can handle non-200 responses from Spring’s ~RestTemplate~.

The project problem-service is a simple Spring Boot app that doubles any number coming in, but every third time it sends an error back. The project consumer has a service that calls the doubling service in problem-service and gives back the result.

Run ./gradlew bootRun in both project to run them both.

Port and Endpoint information:

ProjectPortEndpointResponse Status
problem-service9090/someService/{value}/double200 or 406
consumer8080/myService/{value}/calculate200

Example of hitting the service in consumer

> curl -v http://localhost:8080//myService/42/calculate
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET //myService/42/calculate HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.1
> Accept: */*
>
< HTTP/1.1 200
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Wed, 29 Nov 2017 16:13:06 GMT
<
* Connection #0 to host localhost left intact
{"result":84,"error":null}% 

> curl -v http://localhost:8080//myService/42/calculate
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET //myService/42/calculate HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.1
> Accept: */*
>
< HTTP/1.1 200
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Wed, 29 Nov 2017 16:13:08 GMT
<
* Connection #0 to host localhost left intact
{"result":null,"error":{"description":"Leeroy Jenkins!"}}% 

error-prone-restemplate's People

Contributors

squarepegsys avatar

Stargazers

Luiz Carlos Batista de Cerqueira avatar Akif Hatipoğlu avatar Robert Mircea avatar

Watchers

 avatar James Cloos avatar

Forkers

danilsharf akasse

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.