Navigation Menu

Skip to content

Commit

Permalink
Support not "/d/" path
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Feb 16, 2018
1 parent 24a4933 commit 82311bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 10 additions & 1 deletion lib/groonga/client.rb
Expand Up @@ -222,7 +222,7 @@ def build_url(options)
scheme = (options.delete(:protocol) || "gqtp").to_s
host = options.delete(:host) || options.delete(:address) || "127.0.0.1"
port = options.delete(:port) || default_port(scheme)
path = options.delete(:path)
path = options.delete(:path) || default_path(schema)
user = options.delete(:user)
password = options.delete(:password)
if user and password
Expand Down Expand Up @@ -263,6 +263,15 @@ def default_port(scheme)
end
end

def default_path(scheme)
case scheme
when "http", "https"
"/d/"
else
nil
end
end

def groonga_command_name?(name)
/\A[a-zA-Z][a-zA-Z\d_]+\z/ === name.to_s
end
Expand Down
7 changes: 6 additions & 1 deletion lib/groonga/client/protocol/http/path-resolvable.rb
Expand Up @@ -21,7 +21,12 @@ class HTTP
module PathResolvable
private
def resolve_path(uri, path)
uri.path.chomp("/") + path
path_prefix = uri.path.chomp("/")
if path_prefix.empty?
path
else
path.sub(/\A\/d/) {path_prefix}
end
end
end
end
Expand Down

0 comments on commit 82311bd

Please sign in to comment.