Spring MVC Http Interfaces - How to Create a Rest Client with almost no code!

Поділитися
Вставка
  • Опубліковано 15 лис 2024

КОМЕНТАРІ • 39

  • @Salvvy
    @Salvvy 8 місяців тому +12

    Fantastic introduction to Http Interfaces. Would love to see how this can interact with APIs with OAuth (if at all)

    • @mrcoder9401
      @mrcoder9401 8 місяців тому +1

      +1, Would love to see how this can interact with APIs with OAuth

  • @arghyamitra3281
    @arghyamitra3281 8 місяців тому +11

    Great 💯 love to see how to add interceptor ( eg: want to add a header ) nd error handling with it

  • @andytael
    @andytael 8 місяців тому +1

    Maybe a strange question, but doesn't Feign do this already (with Eureka discovery) and it is easy? Or am I missing something. Awesome video!

  • @AgrimRocks
    @AgrimRocks 8 місяців тому +2

    If you are using ultimate edition, you can create new project using spring initializer from within the ide using File -> New Project -> Spring Initializer

    • @DanVega
      @DanVega  8 місяців тому +4

      Thank you! I try to remember that not everyone is using IntelliJ ultimate edition and thats why i use start.spring.io

  • @AdrianVrabie
    @AdrianVrabie 8 місяців тому +1

    That's great for demos and MVPs. In RL you might need to put some specific headers in the calls, which can be path dependent :)

  • @aravintht.k9276
    @aravintht.k9276 8 місяців тому

    Hi Dan, Great video. Can we handle exceptions thrown from the other service using @ControllerAdvice like we normally do or it has any restrictions on that?

  • @renatmirzoev2167
    @renatmirzoev2167 8 місяців тому +4

    But what if I want to have some custom error handler for cases like Not Found? Or throw an exception?

  • @replicant777
    @replicant777 8 місяців тому

    Hi Dan! Great video! Currently we are on spring boot 2 and use feign (incl some spring integrations like oauth2 or decoders) for creating rest clients to all apis where there are no public java client apis available. Works really great and we love the declarative style. What's the benefit of using this new spring way and will spring feign support be discontinued?

  • @manojdahiya9332
    @manojdahiya9332 8 місяців тому +1

    Hi Dan,
    What do you think about using openfeign

  • @RicardoSilvaTripcall
    @RicardoSilvaTripcall 8 місяців тому +1

    Another great tutorial Dan, congrats.
    Silly question, how to maintain the json field order in the response? They are all over the place here :)

    • @JamesStansell
      @JamesStansell 8 місяців тому +2

      It's the http command sorting the fields. It has the --unsorted param to output the result with the fields in the order sent by the application.

    • @RicardoSilvaTripcall
      @RicardoSilvaTripcall 8 місяців тому

      @@JamesStansell Thanks for the reply, --unsorted solved the problem, it was my first time using httpie.

  • @richardbenes9
    @richardbenes9 8 місяців тому

    Nice tutorial, thanks. What about handling non-200 return codes though?

  • @JamesStansell
    @JamesStansell 8 місяців тому +1

    Thanks Dan! I am really curious to know if the fields of the Geo class populated correctly :)

    • @manojdahiya9332
      @manojdahiya9332 8 місяців тому +1

      @JamesStansell
      No, we need to use json property to set the data in Geo class field

  • @cviniciusm
    @cviniciusm 8 місяців тому

    I would like to suggest to show us an approach of using Polymorphism to create a common contract for UserRestClient and UserHttpClient because in practice we can use this approach to migrate from another/previous client to these new ones by just injecting the right client.

  • @AndreTiconaRollano
    @AndreTiconaRollano 4 місяці тому

    Hey Dan, is there a way to use HttpInterfaces and RestClient with Spring Cloud to point to service names instead of urls? I'd appreciate if you could point me to any documentation on this regard.

  • @bibahbibah5108
    @bibahbibah5108 5 місяців тому

    spring boot 3.2 has very nice futures.
    it's a remplacement of feign dependencies, i hope that we can do wht feign do (headers and interceptor )

  • @amjedallaya9688
    @amjedallaya9688 8 місяців тому

    Thnx Dan, great video as usual, but can you please try to use dark mode for the videos...
    as a member of dracula developers community I really find it hard to follow the code with all these brightness 😅🤣

  • @arunks4706
    @arunks4706 Місяць тому

    How do we set the connection timeout and readtimeout ,if we go for HttpInterfaces and Rest client ,which are important parameters in micro services.

  • @hassanrefaat572
    @hassanrefaat572 8 місяців тому +1

    how about if i want to handle the exception which is maybe happen form the upstream service how could i do that?

  • @zikaima
    @zikaima 8 місяців тому +1

    Hi Dan,I would like to ask how to use restclient to retry http requests upon failure, and whether spring-retry can be used.

    • @mrngwozdz
      @mrngwozdz 4 місяці тому

      Use interceptions. Dań has video on that subkect

  • @AleksandarT10
    @AleksandarT10 8 місяців тому

    Hopefully the Spring team adds some kind of annotation on top of the interface so we dont have to do the boiler plate code in the future!

  • @DineshRN751
    @DineshRN751 8 місяців тому

    Using this approach with webclient for a while now, and it kind of gets messy creating beans for each rest. Spring Boot should have some annotation or something to solve this.. Or a custom annotation to do this?

  • @oskar9136
    @oskar9136 8 місяців тому +1

    Hi Dan!

  • @brayanhernandezmora8619
    @brayanhernandezmora8619 8 місяців тому

    Junior question it’s feing client good for doing this ?

  • @morkhoudia9
    @morkhoudia9 8 місяців тому

    Hi Dan , it will be intéressed a tutorial to use web client calling the use api by iterating and populate to h2 and benching for reactive and a non reactive client...

  • @ЗінаїдаПетрівна-в1ф
    @ЗінаїдаПетрівна-в1ф 6 місяців тому

    how to modify request headers in this case (for example, with some bearer token )?

  • @maksimmuruev423
    @maksimmuruev423 7 місяців тому +1

    Buy what will happen if gateway is not available.. or its return some specific JSON error? We are in network it has no 100% response guarantee.

    • @DanVega
      @DanVega  7 місяців тому

      It's using the RestClient under the hood, you could implement something like retry...

  • @subba18
    @subba18 6 місяців тому

    How HTTP Interface is different from Spring Cloud OpenFeign?

  • @Razpirato
    @Razpirato 8 місяців тому

    It be great if you could add retries.

  • @scitechplusexplorer2484
    @scitechplusexplorer2484 8 місяців тому +1

    Hi Dan! Nice video.
    Can you please make some fresh content related to Spring GraphQL, although u have made it, but still once again, but not just basics, some pretty advanced stuff!!