http_controller.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //#pragma once
  2. //#include "http_define.h"
  3. //#if USE_NET_HTTP_WEBSITE
  4. //#include "http_request.h"
  5. //#include "http_response.h"
  6. //#include "http_reqpack.h"
  7. //#include "http_interface.h"
  8. //#define _DBL_MIN 2.2250738585072014e-308 // min positive value
  9. //#define _DBL_MAX 1.7976931348623158e+308 // max value
  10. //#define _INT_MIN (-2147483647 - 1)
  11. //#define _INT_MAX 2147483647
  12. //#define _UINT_MAX 0xffffffff
  13. //#define _LONG_MIN (-2147483647L - 1)
  14. //#define _LONG_MAX 2147483647L
  15. //#define _ULONG_MAX 0xffffffff
  16. //#ifndef _LLONG_MAX
  17. //#define _LLONG_MAX 9223372036854775807
  18. //#endif
  19. //#define _LLONG_MIN (-9223372036854775807 - 1)
  20. //#define _ULLONG_MAX 0xffffffffffffffff
  21. //#define _INT8_MIN (-127 - 1)
  22. //#define _INT16_MIN (-32767 - 1)
  23. //#define _INT32_MIN (-2147483647 - 1)
  24. //#define _INT64_MIN (-9223372036854775807 - 1)
  25. //#define _INT8_MAX 127
  26. //#define _INT16_MAX 32767
  27. //#define _INT32_MAX 2147483647
  28. //#define _INT64_MAX 9223372036854775807
  29. //#define _UINT8_MAX 0xff
  30. //#define _UINT16_MAX 0xffff
  31. //#define _UINT32_MAX 0xffffffff
  32. //#define _UINT64_MAX 0xffffffffffffffff
  33. //#define _FLT_MIN 1.175494351e-38F // min normalized positive value
  34. //#define _FLT_MAX 3.402823466e+38F // max value
  35. //using namespace ylib::network::http;
  36. //
  37. //// 成功回复
  38. //#define REPLY_SUCC rpjson()["code"] = 200;return RT_OK
  39. //// 自定义回复
  40. //#define REPLY(CODE,MSG) rpjson()["code"] = CODE;rpjson()["msg"]=MSG;return RT_OK
  41. //// 失败回复
  42. //#define REPLY_ERROR(MSG) rpjson()["code"] = -1;rpjson()["msg"]=MSG;return RT_OK
  43. ///**********************************************************
  44. // * Class:Http控制器接口
  45. // *********************************************************/
  46. ////#define check_qry_json(NAME) request()->parser()->json()[NAME].is_empty()
  47. //#define qry_json_string(NAME) request()->parser()->json()[NAME].to<std::string>(true)
  48. //#define qry_json_uint32(NAME) request()->parser()->json()[NAME].to<uint32>(true)
  49. //#define qry_json_uint64(NAME) request()->parser()->json()[NAME].to<uint64>(true)
  50. //#define qry_json_int32(NAME) request()->parser()->json()[NAME].to<int32>(true)
  51. //#define qry_json_double(NAME) request()->parser()->json()[NAME].to<double>(true)
  52. //#define qry_json_short(NAME) request()->parser()->json()[NAME].to<short>(true)
  53. //#define qry_json_bool(NAME) request()->parser()->json()[NAME].to<bool>(true)
  54. //namespace ylib
  55. //{
  56. // namespace network
  57. // {
  58. // namespace http
  59. // {
  60. // class router;
  61. // class controller :public network::http::interface_
  62. // {
  63. // public:
  64. // controller();
  65. // ~controller();
  66. // network::http::request* request();
  67. // network::http::response* response();
  68. //
  69. // //min和max为<=或>= ,若填-1则不使用该条件
  70. // std::string qry_string(const std::string& name,bool exception = true);
  71. // int32 qry_int32(const std::string& name, bool exception = true);
  72. // uint32 qry_uint32(const std::string& name, bool exception = true);
  73. // int64 qry_int64(const std::string& name, bool exception = true);
  74. // uint64 qry_uint64(const std::string& name, bool exception = true);
  75. // double qry_double(const std::string& name, bool exception = true);
  76. // float qry_float(const std::string& name, bool exception = true);
  77. // bool qry_empty(const std::string& name, bool exception = true);
  78. // bool qry_bool(const std::string& name, bool exception = true);
  79. // ylib::buffer qry_buffer(const std::string& name, bool exception);
  80. //
  81. // // 请求参数
  82. // bool request_param(const std::string& name, std::string& value);
  83. //
  84. // // 获取回复JSON
  85. // inline ylib::json& rpjson() { return response()->sjson["data"]; }
  86. // inline ylib::json& rpcode() { return response()->sjson["code"]; }
  87. // //inline ylib::json& rp() { return response()->sjson["code"]; }
  88. // inline void rp(int code, const std::string& msg = "", const ylib::json& data = ylib::json())
  89. // {
  90. // response()->sjson["code"] = code;
  91. // response()->sjson["msg"] = msg;
  92. // response()->sjson["data"] = data;
  93. // };
  94. //
  95. // void send(const ylib::json& data);
  96. //
  97. // friend class router;
  98. // private:
  99. // network::http::reqpack* m_reqpack = nullptr;
  100. // };
  101. // }
  102. // }
  103. //}
  104. //#endif