You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 年之前
1234567891011121314151617181920212223
  1. const request = require("superagent");
  2. function get_url(socket, path) {
  3. if (!path) {
  4. path = "";
  5. }
  6. return socket.request.headers.origin + path;
  7. }
  8. // Authenticates a partial request created using superagent
  9. function xhiveframework_request(path, socket) {
  10. const partial_req = request.get(get_url(socket, path));
  11. if (socket.sid) {
  12. return partial_req.query({ sid: socket.sid });
  13. } else if (socket.authorization_header) {
  14. return partial_req.set("Authorization", socket.authorization_header);
  15. }
  16. }
  17. module.exports = {
  18. get_url,
  19. xhiveframework_request,
  20. };