How to make groovy's http-builder "built-in"?

In some of our development we’re using http-builder and we initialize it like this:

@Grab(group="org.codehaus.groovy.modules.http-builder", module="http-builder", version="0.7.1")
import groovyx.net.http.HTTPBuilder;

I wonder how we could make it part of the xwiki instance for good, rather that using a @grab call in every pages. Any tip ?

Thanks!

Idea: You could just install it with the Extension Manager (using advanced search).

Yes the best is to install org.codehaus.groovy.modules.http-builder:http-builder with extension Manager. Since simple search is not supported out of the box for Maven central you will have to use “Advanced Search” (which ask you for the id and version of the extension you want to install). I would recommend to install it “On Farm” if you have several wikis.

Hi @mhow2, How are you? Could the HTTP Application be helpful for your use case? I released it recently to ease HTTP operations from XWiki scripts. Let me know if you have specific needs around it. Vincent, Thomas, all, the (minimal) proposed API is just a suggestion, I’m not sure I chose the most appropriate method names yet, so your feedback is welcome.

Cheers

The correct way to install it is to use the following identiifder and version from the extension manager:

  • Identifier: `org.xwiki.contrib:xwiki-http-lib
  • Version: 1.0

There might be something wrong with the artefact advertised on HTTP Application page, I’ll fix that.

You imported the parent pom in e.x.o. instead of the java (API) module. Also, I’m not sure “Application” is a good name for an extension that provides at this point only a Java API (script service).

Thank you Marius, I fixed the extension descriptor and I updated its name indeed, please let me know if you have other suggestions. I favored “HTTP Library” over “HTTP API” so far because even though the API implementation is very lightweight, there’s an API one the one hand and an implementation on the other hand imho. Let me know what you think?

I also agree that HTTP API is better and matches our best practices so far. “Application” is reserved to apps offering wiki pages.

So I’ve got it working by installing the package from the extension manager, thanks !
To answer @slauriere: hi ! I’m fine thanks !
We’re using http-builder for more advanced feature like manipulating headers and authentication. I’m not sure your HTTP API package would fit.

1 Like