From 7d808824fff06a2d92374cd6788201d70d3b8f9e Mon Sep 17 00:00:00 2001 From: Rob Rudin Date: Wed, 4 May 2016 09:04:09 -0400 Subject: [PATCH] Added example project that uses HTTPBuilder --- .editorconfig | 16 +++++++++ .gitignore | 4 ++- examples/httpbuilder-project/README.md | 0 examples/httpbuilder-project/build.gradle | 33 +++++++++++++++++++ .../httpbuilder-project/gradle.properties | 5 +++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .editorconfig create mode 100644 examples/httpbuilder-project/README.md create mode 100644 examples/httpbuilder-project/build.gradle create mode 100644 examples/httpbuilder-project/gradle.properties diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..9427c75e8 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = tab +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[*.java] +indent_size = 4 diff --git a/.gitignore b/.gitignore index a6d3fdc2f..f9fe35bea 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,6 @@ examples/shell-project/.gradle examples/shell-project/.settings examples/shell-project/.project examples/shell-project/.classpath -examples/minimal-project/.gradle \ No newline at end of file +examples/minimal-project/.gradle +.idea +*.iml diff --git a/examples/httpbuilder-project/README.md b/examples/httpbuilder-project/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/examples/httpbuilder-project/build.gradle b/examples/httpbuilder-project/build.gradle new file mode 100644 index 000000000..246032aac --- /dev/null +++ b/examples/httpbuilder-project/build.gradle @@ -0,0 +1,33 @@ +buildscript { + dependencies { + classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.7' + } +} + +plugins { + id "com.marklogic.ml-gradle" version "2.1.0" +} + +/* + * This shows an example of using RESTClient - https://github.com/jgritman/httpbuilder/wiki/RESTClient - to talk to + * our REST API server. + */ +task httpTest { + doLast { + def client = new groovyx.net.http.RESTClient("http://" + mlHost + ":" + mlRestPort) + client.auth.basic mlUsername, mlPassword + + println client.get(path: '/').data + } +} + +/* + * You can also easily get an instance of a MarkLogic DatabaseClient (part of the Java API) for talking to the REST + * API server. + */ +task clientTest(type: com.marklogic.gradle.task.MarkLogicTask) { + doLast { + def client = newClient() + println "DatabaseClient: " + client + } +} diff --git a/examples/httpbuilder-project/gradle.properties b/examples/httpbuilder-project/gradle.properties new file mode 100644 index 000000000..0fb42b97a --- /dev/null +++ b/examples/httpbuilder-project/gradle.properties @@ -0,0 +1,5 @@ +mlHost=localhost +mlAppName=httpbuilder-project +mlRestPort=8130 +mlUsername=admin +mlPassword=admin