ruby - sinatra 的问题
伊谢尔伦
伊谢尔伦 2017-04-22 08:59:41
0
0
489

看不懂 ccng file_controller 里的这几行代码,sinatra 应用不都是get '/XXX' {xxx}这种形式吗?

    get "#{path_guid}/instances/:instance_id/files", :files
    def files(guid, search_param, path = nil)
      app = find_guid_and_validate_access(:read, guid)

      info = get_file_uri_for_search_param(app, path, search_param)

      headers = {}
      range = env["HTTP_RANGE"]
      if range
        headers["Range"] = range
      end

      uri = info.file_uri_v2
      uri = add_tail(uri) if params.include?("tail")
      [HTTP::FOUND, {"Location" => uri}, nil]
    end

    get "#{path_guid}/instances/:instance_id/files/*", :files
    def http_get(uri, headers, username, password)
      client = HTTPClient.new
      client.set_auth(nil, username, password) if username && password
      client.get(uri, :header => headers)
    end
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template