You are here

function cors_admin_form in CORS 7

CORS admin configuration form.

1 string reference to 'cors_admin_form'
cors_menu in ./cors.module
Implements hook_menu().

File

./cors.module, line 28
Allows Cross-origin resource sharing.

Code

function cors_admin_form($form, &$form_state) {
  $form = array();
  $cors_domains = '';
  foreach (variable_get('cors_domains', array()) as $path => $domain) {
    $cors_domains .= $path . '|' . $domain . "\n";
  }
  $form['cors_domains'] = array(
    '#type' => 'textarea',
    '#title' => t('Domains'),
    '#description' => t('A list of paths and corresponding domains to enable for CORS. Multiple entries should be separated by a comma. Enter one value per line separated by a pipe, in this order:
   <ul>
     <li>Internal path</li>
     <li>Access-Control-Allow-Origin. Use &lt;mirror&gt; to echo back the Origin header.</li>
     <li>Access-Control-Allow-Methods</li>
     <li>Access-Control-Allow-Headers</li>
     <li>Access-Control-Allow-Credentials</li>
    </ul>
    Examples:
    <ul>
      <li>*|http://example.com</li>
      <li>api|http://example.com:8080 http://example.com</li>
      <li>api/*|&lt;mirror&gt;,https://example.com</li>
      <li>api/*|&lt;mirror&gt;|POST|Content-Type,Authorization|true</li>
    </ul>'),
    '#default_value' => $cors_domains,
    '#rows' => 10,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  return $form;
}