Module: PrestoHTTP::API
- Includes:
- PrestoCore::Utils, Rack::Utils
- Included in:
- ClassAPI, InstanceAPI
- Defined in:
- lib/presto/http.rb,
lib/presto/http/api.rb
Constant Summary
Constant Summary
Constants included from PrestoCore::Utils
PrestoCore::Utils::PATH_MODIFIERS, PrestoCore::Utils::STATUS__NOT_FOUND, PrestoCore::Utils::STATUS__OK, PrestoCore::Utils::STATUS__PERMANENT_REDIRECT, PrestoCore::Utils::STATUS__REDIRECT, PrestoCore::Utils::STATUS__RESTRICTED, PrestoCore::Utils::STATUS__SERVER_ERROR
Instance Method Summary (collapse)
- - (Object) authorization_form (also: #auth_form)
-
- (String) build_path(*args)
builds path from given args.
-
- (String) get(*args, &proc)
performing an internal GET request.
-
- (String) mime_type(type)
get mime-type by extension.
- - (Object) normalize_path(*args)
-
- (String) post(*args, &proc)
performing an internal POST request.
-
- (String) route(action = nil, *args)
(also: #r)
return controller root + action route.
-
- (String) xhr_get(*args, &proc)
(also: #xhr)
performing an internal XMLHttpRequest GET request.
-
- (String) xhr_post(*args, &proc)
performing an internal XMLHttpRequest POST request.
Methods included from PrestoCore::Utils
build_path, #extract_controllers, is_controller?, normalize_path, rootify_url
Instance Method Details
- (Object) authorization_form Also known as: auth_form
72 73 74 |
# File 'lib/presto/http/api.rb', line 72 def @authorization_form ||= ::PrestoHTTP::HTMLAuth. end |
- (String) build_path(*args)
builds path from given args
64 65 66 |
# File 'lib/presto/http/api.rb', line 64 def build_path *args ::PrestoCore::Utils.build_path *args end |
- (String) get(*args, &proc)
performing an internal GET request
81 82 83 |
# File 'lib/presto/http/api.rb', line 81 def get *args, &proc ::PrestoCore::Browser.new(@controller, env).body *args, &proc end |
- (String) mime_type(type)
get mime-type by extension
57 58 59 |
# File 'lib/presto/http/api.rb', line 57 def mime_type type ::Rack::Mime.mime_type type end |
- (Object) normalize_path(*args)
68 69 70 |
# File 'lib/presto/http/api.rb', line 68 def normalize_path *args ::PrestoCore::Utils.normalize_path *args end |
- (String) post(*args, &proc)
performing an internal POST request
88 89 90 |
# File 'lib/presto/http/api.rb', line 88 def post *args, &proc ::PrestoCore::Browser.new(@controller, env, 'POST').body *args, &proc end |
- (String) route(action = nil, *args) Also known as: r
return controller root + action route. any other arguments will be added to path.
27 28 29 30 31 32 |
# File 'lib/presto/http/api.rb', line 27 def route action = nil, *args if (map = @controller.ctrl.action_map) && (route = map[action]) return build_path route, *args end build_path @controller.http.root, action, *args end |
- (String) xhr_get(*args, &proc) Also known as: xhr
performing an internal XMLHttpRequest GET request
95 96 97 |
# File 'lib/presto/http/api.rb', line 95 def xhr_get *args, &proc ::PrestoCore::Browser.new(@controller, env, 'GET', true).body *args, &proc end |
- (String) xhr_post(*args, &proc)
performing an internal XMLHttpRequest POST request
104 105 106 |
# File 'lib/presto/http/api.rb', line 104 def xhr_post *args, &proc ::PrestoCore::Browser.new(@controller, env, 'POST', true).body *args, &proc end |