Skip to content

Commit

Permalink
Rename Meteor.http to HTTP. Backwards compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
glasser committed Jul 26, 2013
1 parent ce16794 commit a5c061e
Show file tree
Hide file tree
Showing 25 changed files with 89 additions and 85 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- `Meteor.default_connection` - `Meteor.connection`
- `Meteor.default_server` - `Meteor.server`
- `Meteor.connect` - `DDP.connect`
- `Meteor.http` - `HTTP`


## v0.6.4.1
Expand Down
22 changes: 11 additions & 11 deletions docs/client/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -2814,9 +2814,9 @@ <h2 id="ejson"><span>EJSON</span></h2>
return this.toHexString();
};

<h2 id="meteor_http"><span>Meteor.http</span></h2>
<h2 id="HTTP"><span>HTTP</span></h2>

`Meteor.http` provides an HTTP API on the client and server. To use
`HTTP` provides an HTTP request API on the client and server. To use
these functions, add the HTTP package to your project with `$ meteor add
http`.

Expand Down Expand Up @@ -2887,22 +2887,22 @@ <h2 id="meteor_http"><span>Meteor.http</span></h2>
Meteor.methods({checkTwitter: function (userId) {
check(userId, String);
this.unblock();
var result = Meteor.http.call("GET", "http://api.twitter.com/xyz",
{params: {user: userId}});
var result = HTTP.call("GET", "http://api.twitter.com/xyz",
{params: {user: userId}});
if (result.statusCode === 200)
return true
return false;
}});

Example asynchronous HTTP call:

Meteor.http.call("POST", "http://api.twitter.com/xyz",
{data: {some: "json", stuff: 1}},
function (error, result) {
if (result.statusCode === 200) {
Session.set("twizzled", true);
}
});
HTTP.call("POST", "http://api.twitter.com/xyz",
{data: {some: "json", stuff: 1}},
function (error, result) {
if (result.statusCode === 200) {
Session.set("twizzled", true);
}
});


{{> api_box http_get}}
Expand Down
18 changes: 9 additions & 9 deletions docs/client/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ Template.api.equals = {

Template.api.httpcall = {
id: "meteor_http_call",
name: "Meteor.http.call(method, url [, options] [, asyncCallback])",
name: "HTTP.call(method, url [, options] [, asyncCallback])",
locus: "Anywhere",
descr: ["Perform an outbound HTTP request."],
args: [
Expand Down Expand Up @@ -1632,30 +1632,30 @@ Template.api.httpcall = {

Template.api.http_get = {
id: "meteor_http_get",
name: "Meteor.http.get(url, [options], [asyncCallback])",
name: "HTTP.get(url, [options], [asyncCallback])",
locus: "Anywhere",
descr: ["Send an HTTP GET request. Equivalent to `Meteor.http.call(\"GET\", ...)`."]
descr: ["Send an HTTP GET request. Equivalent to `HTTP.call(\"GET\", ...)`."]
};

Template.api.http_post = {
id: "meteor_http_post",
name: "Meteor.http.post(url, [options], [asyncCallback])",
name: "HTTP.post(url, [options], [asyncCallback])",
locus: "Anywhere",
descr: ["Send an HTTP POST request. Equivalent to `Meteor.http.call(\"POST\", ...)`."]
descr: ["Send an HTTP POST request. Equivalent to `HTTP.call(\"POST\", ...)`."]
};

Template.api.http_put = {
id: "meteor_http_put",
name: "Meteor.http.put(url, [options], [asyncCallback])",
name: "HTTP.put(url, [options], [asyncCallback])",
locus: "Anywhere",
descr: ["Send an HTTP PUT request. Equivalent to `Meteor.http.call(\"PUT\", ...)`."]
descr: ["Send an HTTP PUT request. Equivalent to `HTTP.call(\"PUT\", ...)`."]
};

Template.api.http_del = {
id: "meteor_http_del",
name: "Meteor.http.del(url, [options], [asyncCallback])",
name: "HTTP.del(url, [options], [asyncCallback])",
locus: "Anywhere",
descr: ["Send an HTTP DELETE request. Equivalent to `Meteor.http.call(\"DELETE\", ...)`. (Named `del` to avoid conflict with JavaScript's `delete`.)"]
descr: ["Send an HTTP DELETE request. Equivalent to `HTTP.call(\"DELETE\", ...)`. (Named `del` to avoid conflict with JavaScript's `delete`.)"]
};


Expand Down
12 changes: 6 additions & 6 deletions docs/client/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ var toc = [
],


"Meteor.http", [
"Meteor.http.call",
{name: "Meteor.http.get", id: "meteor_http_get"},
{name: "Meteor.http.post", id: "meteor_http_post"},
{name: "Meteor.http.put", id: "meteor_http_put"},
{name: "Meteor.http.del", id: "meteor_http_del"}
"HTTP", [
"HTTP.call",
{name: "HTTP.get", id: "meteor_http_get"},
{name: "HTTP.post", id: "meteor_http_post"},
{name: "HTTP.put", id: "meteor_http_put"},
{name: "HTTP.del", id: "meteor_http_del"}
],
"Email", [
"Email.send"
Expand Down
4 changes: 2 additions & 2 deletions packages/facebook/facebook_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var getTokenResponse = function (query) {
var responseContent;
try {
// Request an access token
responseContent = Meteor.http.get(
responseContent = HTTP.get(
"https://graph.facebook.com/oauth/access_token", {
params: {
client_id: config.appId,
Expand Down Expand Up @@ -86,7 +86,7 @@ var getTokenResponse = function (query) {

var getIdentity = function (accessToken) {
try {
return Meteor.http.get("https://graph.facebook.com/me", {
return HTTP.get("https://graph.facebook.com/me", {
params: {access_token: accessToken}}).data;
} catch (err) {
throw new Error("Failed to fetch identity from Facebook. " + err.message);
Expand Down
2 changes: 1 addition & 1 deletion packages/facebook/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Package.describe({
Package.on_use(function(api) {
api.use('oauth2', ['client', 'server']);
api.use('oauth', ['client', 'server']);
api.use('http', ['client', 'server']);
api.use('http', ['server']);
api.use('templating', 'client');
api.use('underscore', 'server');
api.use('random', 'client');
Expand Down
4 changes: 2 additions & 2 deletions packages/github/github_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var getAccessToken = function (query) {

var response;
try {
response = Meteor.http.post(
response = HTTP.post(
"https://github.com/login/oauth/access_token", {
headers: {
Accept: 'application/json',
Expand All @@ -54,7 +54,7 @@ var getAccessToken = function (query) {

var getIdentity = function (accessToken) {
try {
return Meteor.http.get(
return HTTP.get(
"https://api.github.com/user", {
headers: {"User-Agent": userAgent}, // http://developer.github.com/v3/#user-agent-required
params: {access_token: accessToken}
Expand Down
2 changes: 1 addition & 1 deletion packages/github/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Package.describe({
Package.on_use(function(api) {
api.use('oauth2', ['client', 'server']);
api.use('oauth', ['client', 'server']);
api.use('http', ['client', 'server']);
api.use('http', ['server']);
api.use('underscore', 'client');
api.use('templating', 'client');
api.use('random', 'client');
Expand Down
4 changes: 2 additions & 2 deletions packages/google/google_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var getTokens = function (query) {

var response;
try {
response = Meteor.http.post(
response = HTTP.post(
"https://accounts.google.com/o/oauth2/token", {params: {
code: query.code,
client_id: config.clientId,
Expand All @@ -67,7 +67,7 @@ var getTokens = function (query) {

var getIdentity = function (accessToken) {
try {
return Meteor.http.get(
return HTTP.get(
"https://www.googleapis.com/oauth2/v1/userinfo",
{params: {access_token: accessToken}}).data;
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion packages/google/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Package.describe({
Package.on_use(function(api) {
api.use('oauth2', ['client', 'server']);
api.use('oauth', ['client', 'server']);
api.use('http', ['client', 'server']);
api.use('http', ['server']);
api.use(['underscore', 'service-configuration'], ['client', 'server']);
api.use(['random', 'templating'], 'client');

Expand Down
3 changes: 3 additions & 0 deletions packages/http/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// The HTTP object used to be called Meteor.http.
// XXX COMPAT WITH 0.6.4
Meteor.http = HTTP;
2 changes: 1 addition & 1 deletion packages/http/httpcall_client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Meteor.http.call = function(method, url, options, callback) {
HTTP.call = function(method, url, options, callback) {

////////// Process arguments //////////

Expand Down
19 changes: 9 additions & 10 deletions packages/http/httpcall_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,20 @@ populateData = function(response) {
}
};

// XXX rename to HTTP
Meteor.http = {};
HTTP = {};

Meteor.http.get = function (/* varargs */) {
return Meteor.http.call.apply(this, ["GET"].concat(_.toArray(arguments)));
HTTP.get = function (/* varargs */) {
return HTTP.call.apply(this, ["GET"].concat(_.toArray(arguments)));
};

Meteor.http.post = function (/* varargs */) {
return Meteor.http.call.apply(this, ["POST"].concat(_.toArray(arguments)));
HTTP.post = function (/* varargs */) {
return HTTP.call.apply(this, ["POST"].concat(_.toArray(arguments)));
};

Meteor.http.put = function (/* varargs */) {
return Meteor.http.call.apply(this, ["PUT"].concat(_.toArray(arguments)));
HTTP.put = function (/* varargs */) {
return HTTP.call.apply(this, ["PUT"].concat(_.toArray(arguments)));
};

Meteor.http.del = function (/* varargs */) {
return Meteor.http.call.apply(this, ["DELETE"].concat(_.toArray(arguments)));
HTTP.del = function (/* varargs */) {
return HTTP.call.apply(this, ["DELETE"].concat(_.toArray(arguments)));
};
8 changes: 3 additions & 5 deletions packages/http/httpcall_server.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
Meteor.http = Meteor.http || {};

var path = Npm.require('path');
var request = Npm.require('request');
var url_util = Npm.require('url');

// _call always runs asynchronously; Meteor.http.call, defined below,
// _call always runs asynchronously; HTTP.call, defined below,
// wraps _call and runs synchronously when no callback is provided.
_call = function(method, url, options, callback) {
var _call = function(method, url, options, callback) {

////////// Process arguments //////////

Expand Down Expand Up @@ -106,4 +104,4 @@ _call = function(method, url, options, callback) {
});
};

Meteor.http.call = Meteor._wrapAsync(_call);
HTTP.call = Meteor._wrapAsync(_call);
Loading

0 comments on commit a5c061e

Please sign in to comment.