Skip to content

HTTP Mapping Strawman #93

@clemensv

Description

@clemensv

Just to capture a straw-man for HTTP mappings for discussion purposes - not about the mapping per-se (that might be too early at this point) but to illustrate concrete usage of the properties in the core spec.

With the properties that are in the spec as of today, I'm going to show two candidate mappings for HTTP. One carries an opaque binary payload as-is with the data field being mapped to the HTTP payload, the other carries an event consisting of JSON data. I believe that both scenarios have legitimate use cases.

Upside of the binary mapping is that binary payloads can be routed w/o size penalty. Downside is that you'll have to juggle HTTP headers, which is painful in many environments. Upside up the JSON format is that you have it all in one object, but non-JSON data effectively needs to be treated as binary and base64 encoded.

JSON mapping with JSON data has priority for Microsoft.

Binary: Cloud events properties are mapped to HTTP headers. Content-Type is mapped to the native header.

POST {external} HTTP/1.1
CloudEvents-Namespace: azure.microsoft.com/storage
CloudEvents-EventType: Microsoft.Storage.BlobCreated
CloudEvents-EventTypeVersion: 2018-01-20
CloudEvents-Version: 0.2
CloudEvents-Topic: subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount
CloudEvents-Subject: /blobServices/default/containers/oc2d2817345i200097container/blobs/oc2d2817345i20002296blob
CloudEvents-EventId: 831e1650-001e-001b-66ab-eeb76e069631
CloudEvents-EventTime: 2017-06-26T18:41:00.9584103Z
**Content-Type**: application/x-my-opaque-binary
Content-Length: 1234

{Data}

JSON: Here, all the cloud events properties are mapped inline at the outer scope of a JSON object. The "data" object contains event-specific data, here an Azure blob store event. I think this will be the more common form.

POST {external} HTTP/1.1
Content-Type: application/json
Content-Length: nnnn

{
    "namespace" : "azure.com"
 /oc2d2817345i20002296blob",
    "cloud-events-version": "0.2"
    "event-type": "Microsoft.Storage.BlobCreated",
    "event-type-version": "1",
    "event-time": "2017-06-26T18:41:00.9584103Z",
    "event-id": "831e1650-001e-001b-66ab-eeb76e069631",
   "topic": "subscriptions/{subscription-id}/resourceGroups/Storage/providers/Microsoft.Storage/storageAccounts/xstoretestaccount",
    "subject": "/blobServices/default/containers/oc2d2817345i200097container/blobs
    "schema-url": "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/eventgrid/data-plane/Microsoft.Storage/stable/2018-01-01/Storage.json",
    "data": { 
      "api": "PutBlockList",
      "clientRequestId": "6d79dbfb-0e37-4fc4-981f-442c9ca65760",
      "requestId": "831e1650-001e-001b-66ab-eeb76e000000",
      "eTag": "0x8D4BCC2E4835CD0",
      "contentType": "application/octet-stream",
      "contentLength": 524288,
      "blobType": "BlockBlob",
      "url": "https://oc2d2817345i60006.blob.core.windows.net/oc2d2817345i200097container/oc2d2817345i20002296blob",
      "sequencer": "00000000000004420000000000028963",
      "storageDiagnostics": {
        "batchId": "b68529f3-68cd-4744-baa4-3c0498ec19f0"
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions