<commit_before>extern crate iron;
extern crate rustc_serialize;

use iron::prelude::*;
use iron::status;
use diesel::prelude::*;
use rustc_serialize::json;
use database;

pub fn index(request: &mut Request) -> IronResult<Response> {
    println!("Started GET \"/api\" for {}", request.remote_addr);

    Ok(Response::with((status::Ok, "Welcome to Lugh API!")))
}

pub fn translations(request: &mut Request) -> IronResult<Response> {
    use schema::translations::dsl::*;
    use models::*;

    println!("Started GET \"/api/translations\" for {}", request.remote_addr);

    let connection = database::establish_connection();
    let results = translations.load::<Translation>(&connection)
        .expect("Error loading translations");

    println!("Returns {} translations", results.len());

    let payload = json::encode(&results).unwrap();

    Ok(Response::with((status::Ok, payload)))
}<commit_msg>Set Content-Type header to application/json<commit_after>extern crate iron;
extern crate rustc_serialize;

use iron::headers::ContentType;
use iron::prelude::*;
use iron::status;
use diesel::prelude::*;
use rustc_serialize::json;
use database;

pub fn index(request: &mut Request) -> IronResult<Response> {
    println!("Started GET \"/api\" for {}", request.remote_addr);

    Ok(Response::with((status::Ok, "Welcome to Lugh API!")))
}

pub fn translations(request: &mut Request) -> IronResult<Response> {
    use schema::translations::dsl::*;
    use models::*;

    println!("Started GET \"/api/translations\" for {}", request.remote_addr);

    let connection = database::establish_connection();
    let results = translations.load::<Translation>(&connection)
        .expect("Error loading translations");

    println!("Returns {} translations", results.len());

    let payload = json::encode(&results).unwrap();

    Ok(Response::with((ContentType::json().0, status::Ok, payload)))
}
{'fraction_non_alphanumeric': 0.17026884554559832, 'fraction_numerical': 0.0005271481286241434, 'mean_word_length': 5.222950819672131, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '6130819', 'n_tokens_mistral': 565, 'n_tokens_neox': 541, 'n_words': 135}