[go: up one dir, main page]

FR: Dry response (- deffered, metadata)

Hello again!

I'm utilizing a small patch to reduce the response size as follows.

I acknowledge that it deviates from the ODATA standard, but it significantly expands the library's applicability and offers substantial size reduction in numerous cases.

I would appreciate it if this could be integrated natively!

# Patch: DRY response
module Safrano::ExpandHandler
  alias orig_edh get_entity_odata_h
  def get_entity_odata_h(entity:, template:) = orig_edh(entity:, template: template.except(:deferr)).except METADATA_K
end

I see three major options:

  1. Global constant to disable meta info.
Safrano::DRY_RESPONCE = true
# or
Safrano::DEFERRED = false
Safrano::METADATA = false
  1. App instance option:
class ODataSrv < Safrano::ServerApp
  publish_service do
    response deferred: false, metadata: false
  end
end
  1. Request option:
curl http://localhost:7000/apples/?$top=1&$skip=2&$dry
# or
curl http://localhost:7000/apples/?$top=1&$skip=2&$shrink=deffered,metadata