<commit_before>class Api::CanvasProxyController < ApplicationController
  
  before_action :validate_token

  respond_to :json

  def index
  end

  def proxy
    api = current_account.canvas_api
    result = api.proxy(params[:type], params, request.body.read)
    response.status = result.code
    
    allowed_headers = [ "content-type", "link", "p3p", "x-canvas-meta", "x-canvas-user-id", 
      "x-rate-limit-remaining", "x-request-context-id", "x-request-cost", 
      "x-request-processor", "x-robots-tag", "x-runtime", "x-session-id", 
      "x-ua-compatible", "x-xss-protection"]

    result.headers.each do |name, val|
      response.headers[name] = val if allowed_headers.include?(name)
    end

    render text: result.body<commit_msg>Get canvas api from user not account<commit_after>class Api::CanvasProxyController < ApplicationController
  
  before_action :validate_token

  respond_to :json

  def index
  end

  def proxy
    api = current_user.canvas_api
    #api = current_account.canvas_api

    result = api.proxy(params[:type], params, request.body.read)
    response.status = result.code
    
    allowed_headers = [ "content-type", "link", "p3p", "x-canvas-meta", "x-canvas-user-id", 
      "x-rate-limit-remaining", "x-request-context-id", "x-request-cost", 
      "x-request-processor", "x-robots-tag", "x-runtime", "x-session-id", 
      "x-ua-compatible", "x-xss-protection"]

    result.headers.each do |name, val|
      response.headers[name] = val if allowed_headers.include?(name)
    end

    render text: result.body
{'fraction_non_alphanumeric': 0.14119922630560927, 'fraction_numerical': 0.0012894906511927789, 'mean_word_length': 3.434285714285714, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4660860', 'n_tokens_mistral': 520, 'n_tokens_neox': 504, 'n_words': 101}