const deprecate = require('depd')('thinkjs');

/**
 * extend controller
 */
module.exports = {
  /**
   * get or set config
   * @param {String} name 
   * @param {Mix} value 
   * @param {String} m 
   */
  config(name, value, m = this.ctx.module){
    return think.config(name, value, m);
  },
  /**
   * get request method
   */
  get method(){
    return this.ctx.method.toLowerCase();
  },
  /**
   * is method
   * @param {String} method 
   */
  isMethod(method){
    return this.method() === method;
  },
  /**
   * is get method
   */
  isGet(){
    return this.method() === 'get';
  },
  /**
   * is post method
   */
  isPost(){
    return this.method === 'post';
  },
  /**
   * check if is ajax request
   * @param {String} method 
   */
  isAjax(method){
    if(method && !this.method(method)){
      return false;
    }
    return this.header('x-requested-with') === 'XMLHttpRequest';
  },
  /**
   * is jsonp request
   */
  isJsonp(){

  },
  jsonp(){

  },
  /**
   * 
   * @param {String} name 
   * @param {Mixed} value 
   */
  get(name, value){
    deprecate('controller.get is deprecate, please use controller.query instead. it will removed in ThinkJS 3.1');
    return this.ctx.param(name, value);
  },
  /**
   * get query data
   * @param {String} name 
   * @param {Mixed} value 
   */
  query(name, value){
    return this.ctx.param(name, value);
  },
  /**
   * get or set post data
   * @param {String} name 
   * @param {Mixed} value 
   */
  post(name, value){
    return this.ctx.post(name, value);
  },
  /**
   * get or set file data
   * @param {String} name 
   * @param {Mixed} value 
   */
  file(name, value){
    return this.ctx.file(name, value);
  },
  /**
   * get or set cookies
   * @param {String} name 
   * @param {String} value 
   * @param {Object} options 
   */
  cookie(name, value, options){
    return this.ctx.cookie(name, value, options);
  },
  /**
   * get or set header
   * @param {String} name 
   * @param {Mixed} value 
   */
  header(name, value){

  },
  /**
   * get userAgent header
   */
  get userAgent(){
    return this.ctx.userAgent();
  },
  /**
   * get referer header
   */
  get referrer(){
    return this.ctx.referer();
  },
  /**
   * get referer header
   */
  get referer(){
    return this.ctx.referer();
  },
  /**
   * Perform a 302 redirect to `url`.
   * @param {String} url 
   * @param {String} alt 
   */
  redirect(url, alt){
    return this.ctx.redirect(url, alt);
  }
}
@@ -2099,18 +2099,16 @@
 serAgent
-()
 ;%0A  %7D,%0A 
@@ -2140,28 +2140,24 @@
 der%0A   */%0A  
-get 
 referrer()%7B%0A
@@ -2149,24 +2149,32 @@
 %0A  referrer(
+onlyHost
 )%7B%0A    retur
@@ -2184,32 +2184,40 @@
 his.ctx.referer(
+onlyHost
 );%0A  %7D,%0A  /**%0A  
@@ -2250,20 +2250,16 @@
 /%0A  
-get 
 referer(
 )%7B%0A 
@@ -2254,16 +2254,24 @@
 referer(
+onlyHost
 )%7B%0A    r
@@ -2293,16 +2293,24 @@
 referer(
+onlyHost
 );%0A  %7D,%0A

Optimize some code in controller