Heim  >  Fragen und Antworten  >  Hauptteil

ruby - sinatra 的问题

看不懂 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
伊谢尔伦伊谢尔伦2761 Tage vor472

Antworte allen(0)Ich werde antworten

Keine Antwort
  • StornierenAntwort