<commit_before>import CoreObject from 'core-object';
import assign from 'lodash/object/assign';
import assert from 'assert';

export default CoreObject.extend({

  render() {
    this._rendered = true;
    return this.response.render(...arguments);
  },

  _run() {
    let params = assign({}, this.request.query, this.request.body);
    let responder = Promise.method(this.respond.bind(this));
    responder(params)
      .then(() => {
        assert(!this._rendered && !this.response.headersSent, `Your action didn't call this.render or finish the request.`);
      }).catch((error) => {
        this.next(error);
      });
  }

});<commit_msg>Add content negotiation to actions<commit_after>import CoreObject from 'core-object';
import assign from 'lodash/object/assign';
import assert from 'assert';

export default CoreObject.extend({

  render() {
    this._rendered = true;
    return this.response.render(...arguments);
  },

  _run() {
    let params = assign({}, this.request.query, this.request.body);
    let responder = this.respond;
    Object.keys(this).forEach((key) => {
      if (this.request.accepts(key)) {
        responder = this[key];
      }
    });
    responder = Promise.method(responder.bind(this));
    responder(params)
      .then(() => {
        assert(!this._rendered && !this.response.headersSent, `Your action didn't call this.render or finish the request.`);
      }).catch((error) => {
        this.next(error);
      });
  }

});
{'fraction_non_alphanumeric': 0.15882753919563736, 'fraction_numerical': 0.0, 'mean_word_length': 3.1823361823361824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '881022', 'n_tokens_mistral': 446, 'n_tokens_neox': 433, 'n_words': 99}