Sha256: e7766ce1d12a12bb498b3727ed029e572cccd371733f58da7baf7fce217af809

Contents?: true

Size: 889 Bytes

Versions: 4

Compression:

Stored size: 889 Bytes

Contents

get "/api" do
  api_file = File.join("api", "api.json")
  `sed -i 's/SERVER_URI/#{request.env['HTTP_HOST']}/' #{api_file}`
  halt 400, "API Documentation in Swagger JSON is not implemented." unless File.exists?(api_file)
  case @accept
  when "text/html"
    response['Content-Type'] = "text/html"
    index_file = File.join(ENV['HOME'],"swagger-ui/dist/index.html")
    return File.read(index_file)
  when "application/json"
    redirect("/api/api.json")
  else
    halt 400, "unknown MIME type '#{@accept}'"
  end
end

get "/api/api.json" do
  api_file = File.join("api", "api.json")
  `sed -i 's/SERVER_URI/#{request.env['HTTP_HOST']}/' #{api_file}`
  case @accept
  when "text/html"
    response['Content-Type'] = "application/json"
    return File.read(api_file)
  when "application/json"
    return File.read(api_file)
  else
    halt 400, "unknown MIME type '#{@accept}'"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lazar-gui-1.4.2 lib/api.rb
lazar-gui-1.4.1 lib/api.rb
lazar-gui-1.4.0 lib/api.rb
lazar-gui-1.4.0.pre.0 lib/api.rb