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

看不懂 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伐。

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板