From 73da1dd6cb755ff1656566a02e9a46653af09309 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sat, 8 Oct 2022 01:23:54 +0300 Subject: [PATCH] http/client --- ~/Crystal/README.md | 1 + ~/Crystal/http_client.cr | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 ~/Crystal/http_client.cr diff --git a/~/Crystal/README.md b/~/Crystal/README.md index a18e047..4be4467 100644 --- a/~/Crystal/README.md +++ b/~/Crystal/README.md @@ -7,6 +7,7 @@ - [Colorize](Colorize.cr) - Цветной вывод в консоль - [JSON](json.cr) - Пример работы с JSON - [Fiber](schedule.cr) - Пример распаралеливания кода и расписания +- [http/client](http_client.cr) - Пример HTTP клиента ## Stuff - [`irc_bot.cr`](irc_bot.cr) - Реализация клиента (бота) для IRC diff --git a/~/Crystal/http_client.cr b/~/Crystal/http_client.cr new file mode 100644 index 0000000..5f44dcc --- /dev/null +++ b/~/Crystal/http_client.cr @@ -0,0 +1,11 @@ +require "json" +require "http/client" + +minecraft_url = "https://launchermeta.mojang.com/mc/game/version_manifest_v2.json" +response = HTTP::Client.get minecraft_url + +version_manifest = JSON.parse(response.body) + +version = version_manifest["latest"]["release"] + +puts version