add /_info
This commit is contained in:
parent
efd0097cb5
commit
e0699931c3
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
|
bin/
|
||||||
lib/
|
lib/
|
||||||
config.yml
|
config.yml
|
||||||
|
shard.lock
|
||||||
|
4
README.md
Normal file
4
README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
This is my API service
|
||||||
|
|
||||||
|
## methods
|
||||||
|
/api/v1.0/smsru_status
|
@ -7,6 +7,10 @@ version: 0.1.0
|
|||||||
# description: |
|
# description: |
|
||||||
# Short description of ServicesCheck
|
# Short description of ServicesCheck
|
||||||
|
|
||||||
|
targets:
|
||||||
|
api:
|
||||||
|
main: src/Services.cr
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
kemal:
|
kemal:
|
||||||
github: kemalcr/kemal
|
github: kemalcr/kemal
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
|
require "yaml"
|
||||||
require "kemal"
|
require "kemal"
|
||||||
require "./modules/*"
|
require "./modules/*"
|
||||||
|
|
||||||
|
CONFIG = File.open("./config.yml") { |file| YAML.parse(file) }
|
||||||
|
CONFIG.class
|
||||||
|
|
||||||
|
APP = {version: "1.0.0"}
|
||||||
|
|
||||||
get "/" do
|
get "/" do
|
||||||
render "public/index.html"
|
render "public/index.html"
|
||||||
end
|
end
|
||||||
|
16
src/modules/_info.cr
Normal file
16
src/modules/_info.cr
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
require "json"
|
||||||
|
|
||||||
|
get "/info" do |env|
|
||||||
|
version = APP["version"]
|
||||||
|
|
||||||
|
if env.params.query["json"]?
|
||||||
|
env.response.content_type = "application/json"
|
||||||
|
|
||||||
|
data = {version: version}.to_json
|
||||||
|
data
|
||||||
|
else
|
||||||
|
env.response.content_type = "text/plain"
|
||||||
|
|
||||||
|
"Vesrion: #{version}"
|
||||||
|
end
|
||||||
|
end
|
@ -1,9 +1,5 @@
|
|||||||
require "yaml"
|
|
||||||
require "http/client"
|
require "http/client"
|
||||||
|
|
||||||
CONFIG = File.open("./config.yml") { |file| YAML.parse(file) }
|
|
||||||
CONFIG.class
|
|
||||||
|
|
||||||
get "/api/v1.0/smsru_status" do
|
get "/api/v1.0/smsru_status" do
|
||||||
response = HTTP::Client.get "https://sms.ru/my/free?api_id=#{CONFIG["sms.ru"]["api_id"]}&json=1"
|
response = HTTP::Client.get "https://sms.ru/my/free?api_id=#{CONFIG["sms.ru"]["api_id"]}&json=1"
|
||||||
response.body
|
response.body
|
||||||
|
Loading…
Reference in New Issue
Block a user