Module: RestCore

Defined in:
lib/rest-core/middleware/bypass.rb,
lib/rest-core.rb,
lib/rest-core/event.rb,
lib/rest-core/version.rb,
lib/rest-core/util/hmac.rb,
lib/rest-core/util/json.rb,
lib/rest-core/util/smash.rb,
lib/rest-core/util/clash.rb,
lib/rest-core/util/config.rb,
lib/rest-core/client_oauth1.rb,
lib/rest-core/util/parse_link.rb,
lib/rest-core/util/parse_query.rb,
lib/rest-core/client/universal.rb,
lib/rest-core/middleware/retry.rb,
lib/rest-core/middleware/timeout.rb,
lib/rest-core/middleware/defaults.rb,
lib/rest-core/util/dalli_extension.rb,
lib/rest-core/middleware/auth_basic.rb,
lib/rest-core/middleware/oauth2_query.rb,
lib/rest-core/middleware/default_site.rb,
lib/rest-core/middleware/json_request.rb,
lib/rest-core/middleware/default_query.rb,
lib/rest-core/middleware/oauth2_header.rb,
lib/rest-core/middleware/json_response.rb,
lib/rest-core/middleware/common_logger.rb,
lib/rest-core/middleware/oauth1_header.rb,
lib/rest-core/middleware/error_handler.rb,
lib/rest-core/middleware/clash_response.rb,
lib/rest-core/middleware/error_detector.rb,
lib/rest-core/middleware/query_response.rb,
lib/rest-core/middleware/smash_response.rb,
lib/rest-core/middleware/default_headers.rb,
lib/rest-core/middleware/follow_redirect.rb,
lib/rest-core/middleware/default_payload.rb,
lib/rest-core/middleware/error_detector_http.rb

Overview

the simplest middleware

Defined Under Namespace

Modules: ClientOauth1, Config, DalliExtension, Hmac, Json, ParseLink, ParseQuery Classes: AuthBasic, Bypass, Clash, ClashResponse, CommonLogger, DefaultHeaders, DefaultPayload, DefaultQuery, DefaultSite, Defaults, ErrorDetector, ErrorDetectorHttp, ErrorHandler, Event, FollowRedirect, JsonRequest, JsonResponse, Oauth1Header, Oauth2Header, Oauth2Query, QueryResponse, Retry, Smash, SmashResponse, Timeout

Constant Summary

VERSION =
'4.0.0'
Universal =
RestBuilder::Builder.client do
  use DefaultSite   , nil
  use DefaultHeaders, {}
  use DefaultQuery  , {}
  use DefaultPayload, {}
  use JsonRequest   , false
  use AuthBasic     , nil, nil
  use Retry         , 0, Retry::DefaultRetryExceptions
  use Timeout       , 0
  use ErrorHandler  , nil
  use ErrorDetectorHttp

  use SmashResponse , false
  use ClashResponse , false
  use  JsonResponse , false
  use QueryResponse , false
  use FollowRedirect, 10
  use CommonLogger  , method(:puts)
  use Cache         , {}, 600 # default :expires_in 600 but the default
                              # cache {} didn't support it
end

Class Method Summary collapse

Class Method Details

.eagerload(const = self, loaded = {}) ⇒ Object

You might want to call this before launching your application in a threaded environment to avoid thread-safety issue in autoload.



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rest-core.rb', line 53

def self.eagerload const=self, loaded={}
  return if loaded[const.name]
  loaded[const.name] = true
  const.constants(false).each{ |n|
    begin
      c = const.const_get(n)
    rescue LoadError, NameError => e
      warn "RestCore: WARN: #{e} for #{const}\n" \
           "  from #{e.backtrace.grep(/top.+required/).first}"
    end
    eagerload(c, loaded) if c.respond_to?(:constants) && !loaded[n]
  }
end