|
@ -0,0 +1,35 @@ |
|
|
|
|
|
require "kemal" |
|
|
|
|
|
require "../*" |
|
|
|
|
|
require "io" |
|
|
|
|
|
require "file" |
|
|
|
|
|
require "exception" |
|
|
|
|
|
require "uuid" |
|
|
|
|
|
require "uuid/json" |
|
|
|
|
|
require "../../config" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get "/category/m/:id" do |context| |
|
|
|
|
|
begin |
|
|
|
|
|
ret = Category.from_json File.read Statics.data_path+"category/"+context.params.url["id"] |
|
|
|
|
|
rescue ex |
|
|
|
|
|
halt context, status_code: 403, response: ex.to_s |
|
|
|
|
|
end |
|
|
|
|
|
ret.to_json |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
get "/category/d/:id" do |context| |
|
|
|
|
|
ret = Array(Product).new |
|
|
|
|
|
begin |
|
|
|
|
|
cat = Category.from_json File.read Statics.data_path+"category/"+context.params.url["id"] |
|
|
|
|
|
cat.products.each do |product| |
|
|
|
|
|
begin |
|
|
|
|
|
ret.push Product.from_json File.read Statics.data_path+"products/"+product.to_s |
|
|
|
|
|
rescue |
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
|
|
|
end |
|
|
|
|
|
rescue ex |
|
|
|
|
|
halt context, status_code: 403, response: ex.to_s |
|
|
|
|
|
end |
|
|
|
|
|
ret.to_json |
|
|
|
|
|
end |