<commit_before>module API
  class ProjetsController < ActionController::Base
    protect_from_forgery with: :null_session
    before_action :authenticate

    def show
      projet = Projet.find(params[:id])
      render json: projet
    end

    protected
    def authenticate
      authenticate_token || render_interdit
    end

    def authenticate_token
      authenticate_with_http_token do |token, options|
        token == 'test'
      end
    end

    def render_interdit
      self.headers['WWW-authenticate'] = 'Token'
      render json: { error: 'unauthorized', reason: "Access forbidden to this API" }.to_json, status: 401
    end
<commit_msg>erreur 404 si projet n'existe pas<commit_after>module API
  class ProjetsController < ActionController::Base
    protect_from_forgery with: :null_session
    before_action :authenticate

    def show
      begin
        projet = Projet.find(params[:id])
        render json: projet
      rescue
        render json: { error: 'not found', reason: 'Projet not found' }.to_json, status: 404
      end
    end

    protected
    def authenticate
      authenticate_token || render_interdit
    end

    def authenticate_token
      authenticate_with_http_token do |token, options|
        token == 'test'
      end
    end

    def render_interdit
      self.headers['WWW-authenticate'] = 'Token'
      render json: { error: 'unauthorized', reason: "Access forbidden to this API" }.to_json, status: 401
    end

{'fraction_non_alphanumeric': 0.07523939808481532, 'fraction_numerical': 0.008207934336525308, 'mean_word_length': 2.8806366047745358, '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': '2126854', 'n_tokens_mistral': 452, 'n_tokens_neox': 421, 'n_words': 124}