Groovy built-in REST/HTTP client?

前端 未结 7 987
迷失自我
迷失自我 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:06

    I don't think http-builder is a Groovy module, but rather an external API on top of apache http-client so you do need to import classes and download a bunch of APIs. You are better using Gradle or @Grab to download the jar and dependencies:

    @Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1' )
    import groovyx.net.http.*
    import static groovyx.net.http.ContentType.*
    import static groovyx.net.http.Method.*
    

    Note: since the CodeHaus site went down, you can find the JAR at (https://mvnrepository.com/artifact/org.codehaus.groovy.modules.http-builder/http-builder)

提交回复
热议问题