/**
  * Serialize data and create response
  *
  * @param Application $app
  * @param mixed       $data
  * @param string      $format
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function createResponse(Application $app, $data, $format = 'json')
 {
     $content = $app->serialize(array('result' => true, 'data' => $data), $format);
     $guesser = new ExtensionMimeTypeGuesser();
     $type = $guesser->guess('.' . $format);
     if (!$type) {
         $type = 'text/plain';
     }
     return new Response($content, 200, array('Content-Type' => $type, 'Cache-Control' => 's-maxage=3600, public'));
 }
<?php

/**
 * Bootstrap script
 *
 * This file is a part of Portable ZipCode API
 *
 * @copyright 2013 Kazuyuki Hayashi
 * @license   MIT
 * @author    Kazuyuki Hayashi <*****@*****.**>
 */
use KzykHys\ZipFinder\Application;
$loader = (require __DIR__ . '/../vendor/autoload.php');
$app = new Application();
$app['version'] = '1.0.0';
$app['locale'] = 'ja';
$app['debug'] = true;
$app['path.app'] = defined("PHAR_RUNNING") ? 'phar://zip.phar/app' : __DIR__;
$app['path.cache'] = $app['path.app'] . '/cache';
$app['path.api.js'] = $app['path.app'] . '/api.js';
$app['path.sqlite.db'] = (defined("PHAR_RUNNING") ? dirname(Phar::running(false)) : $app['path.app']) . '/zip.sqlite.db';
$app['orm.cache.path'] = '/doctrine/orm';
$app['orm.proxy.path'] = '/doctrine/proxies';
$app['orm.proxy.namespace'] = 'KzykHys\\ZipFinder\\Proxy\\ORM';
$app['api.js'] = "(function(\$){\$.zipSearch=function(a){return \$.ajax({url:'%URL%/'+a,type:'get'})}})(jQuery);";
/*
(function ($) {
    $.zipSearch = function (zipcode) {
        return $.ajax({
            url:  '%URL%' + zipcode,
            type: 'get'