Groovy built-in REST/HTTP client?

前端 未结 7 903
迷失自我
迷失自我 2020-11-28 19:51

I heard that Groovy has a built-in REST/HTTP client. The only library I can find is HttpBuilder, is this it?

Basically I\'m looking for a way to do

相关标签:
7条回答
  • 2020-11-28 20:24

    HTTPBuilder is it. Very easy to use.

    import groovyx.net.http.HTTPBuilder
    
    def http = new HTTPBuilder('https://google.com')
    def html = http.get(path : '/search', query : [q:'waffles'])
    

    It is especially useful if you need error handling and generally more functionality than just fetching content with GET.

    0 讨论(0)
提交回复
热议问题