Module: Capsium::Reactor::Endpoints
- Includes:
- Responses
- Included in:
- Capsium::Reactor
- Defined in:
- lib/capsium/reactor/endpoints.rb,
sig/capsium/reactor/endpoints.rbs
Overview
Serving of the reactor-level endpoints (introspection reports, per-package save), mixed into Reactor.
Instance Method Summary collapse
- #serve_introspection(request, response) ⇒ Object
-
#serve_package_save(request, response) ⇒ Object
POST /package/
/save: folds base plus overlay into a new .cap.
Methods included from Responses
#respond_error, #respond_forbidden, #respond_json, #respond_method_not_allowed, #respond_not_found, #respond_not_implemented, #respond_text
Instance Method Details
#serve_introspection(request, response) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/capsium/reactor/endpoints.rb', line 14 def serve_introspection(request, response) return respond_method_not_allowed(response) unless request.request_method == "GET" report = @introspection.report_for(request.path, params: request.query) return respond_not_found(response) if report.nil? respond_json(response, 200, report) end |
#serve_package_save(request, response) ⇒ Object
POST /package/
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/capsium/reactor/endpoints.rb', line 25 def serve_package_save(request, response) return respond_method_not_allowed(response) unless request.request_method == "POST" name = PACKAGE_SAVE_PATTERN.match(request.path)[:name] mount = @mounts.find { |candidate| candidate.package.name == name } return respond_not_found(response) unless mount return respond_error(response, 403, "package #{name} is read-only") unless mount.writable? respond_json(response, 200, PackageSaver.new(mount).save(@workdir)) end |