Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new base url for thunderstore client #7

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/thunderstore/methods/package_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe Thunderstore::Package do
context "valheim" do
describe ".list_packages" do
it "retrieves all packages" do
WebMock.stub(:get, "https://valheim.thunderstore.io/api/v1/package/")
WebMock.stub(:get, "https://thunderstore.io/api/v1/package/")
.to_return(status: 200, body: File.read("spec/support/All_Packages-1650682645115.json"), headers: {"Content-Type" => "application/json"})

client = Thunderstore::Client.new("valheim")
Expand Down
6 changes: 4 additions & 2 deletions src/thunderstore/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Thunderstore
class Client
property community = ""

BASE_URL = "https://thunderstore.io"

def initialize(@community : String = "")
end

Expand All @@ -14,9 +16,9 @@ module Thunderstore

# Returns the base url for which this client will make API requests to.
def base_url : URI
return URI.parse("https://thunderstore.io") if community.empty?
return URI.parse(BASE_URL) if community.empty?

URI.parse("https://#{community}.thunderstore.io")
URI.parse("#{BASE_URL}/c/#{community}")
end

# Initializes an `HTTP::Client` for the configured `base_url`, and executes a GET request on the specified `path`.
Expand Down