Commit Graph

8 Commits

Author SHA1 Message Date
Adrian Perez de Castro
58ff794d92 Improve loading of HTTP client factories
This introduces a get_http_factory() function which will try to load
a HTTP client library according to the following logic:

1. If the MATRIX_API_HTTP_CLIENT environment variable is defined, it is
   taken as the name of a HTTP client library.
2. Otherwise, if the function paramter is non-nil it is used as the name
   of the HTTP client library to load.
3. Otherwise, the available HTTP client libraries are tried in order,
   and the first one which can be require()'d successfully will be
   used. For now this has only the "chttp" client.
2016-06-28 23:44:20 +03:00
Adrian Perez de Castro
cf14c37e58 Log the HTTP client being used with each request 2016-06-28 23:22:21 +03:00
Adrian Perez de Castro
28477c4db7 Always stringigy returned HTTP status code for logging
This avoids the potential issue in which the status code would be "nil" or
"false", which HTTP client libraries may choose to signal an error condition.
2016-06-28 23:21:04 +03:00
Adrian Perez de Castro
724d7cdd54 Simplify HTTP client API
* The :quote and :unquote methods are now plain functions and no longer
  receive the "self" parameter. This allows to directly use the utility
  functions provided by the HTTP client library.
* Renamed CqHttpClient to plain "httclient". The variable itself is local
  to the script so it does not need to be unique.
2016-06-28 23:20:50 +03:00
Adrian Perez de Castro
a1cf21b839 Implement room:update_room_{topic,aliases,name} 2016-06-23 04:17:15 +03:00
Adrian Perez de Castro
56a57f2e89 Add __tostring metamethods to prototypes
This is nice to have, and aids with debugging and interactive usage.
2016-06-23 04:07:01 +03:00
Adrian Perez de Castro
cafb8724e3 Import rough implementation of matrix.client 2016-06-23 03:54:48 +03:00
Adrian Perez de Castro
6528727cff Initial import: low-level API wrapper 2016-06-23 03:49:04 +03:00