ctx.close();
}
private static Triplet<String, Map<String,Object>, Optional<String>> getGremlinScript(final FullHttpRequest request) {
if (request.getMethod() == GET) {
final QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
final List<String> gremlinParms = decoder.parameters().get(Tokens.ARGS_GREMLIN);
if (null == gremlinParms || gremlinParms.size() == 0)
throw new IllegalArgumentException("no gremlin script supplied");
final String script = gremlinParms.get(0);
if (script.isEmpty()) throw new IllegalArgumentException("no gremlin script supplied");
// query string parameters - take the first instance of a key only - ignore the rest
final Map<String,Object> bindings = new HashMap<>();
decoder.parameters().entrySet().stream().filter(kv -> !kv.getKey().equals(Tokens.ARGS_GREMLIN))
.forEach(kv -> bindings.put(kv.getKey(), kv.getValue().get(0)));
final List<String> languageParms = decoder.parameters().get(Tokens.ARGS_LANGUAGE);
final Optional<String> language = (null == languageParms || languageParms.size() == 0) ?
Optional.empty() : Optional.ofNullable(languageParms.get(0));
return Triplet.with(script, bindings, language);
} else {