Skip to content

Use context header to accept context instead of modifying body #7438

Closed
@cbaker6

Description

@cbaker6

New Feature / Enhancement Checklist

Current Limitation

Currently, context can only be used by injecting a _context key/value into the body when using REST. This is problematic for SDK's that encode objects without modifying the body like the Swift SDK. This was originally discussed on community.parseplatform.org.

Feature / Enhancement Description

Currently, context is setup to be accepted in the header, but doesn't have an actual header:

export function handleParseHeaders(req, res, next) {
var mount = getMountForRequest(req);
var info = {
appId: req.get('X-Parse-Application-Id'),
sessionToken: req.get('X-Parse-Session-Token'),
masterKey: req.get('X-Parse-Master-Key'),
installationId: req.get('X-Parse-Installation-Id'),
clientKey: req.get('X-Parse-Client-Key'),
javascriptKey: req.get('X-Parse-Javascript-Key'),
dotNetKey: req.get('X-Parse-Windows-Key'),
restAPIKey: req.get('X-Parse-REST-API-Key'),
clientVersion: req.get('X-Parse-Client-Version'),
context: {},
};

Adding a new header X-Parse-Cloud-Context will address the issue.

Example Use Case

Using REST:

const req = request({
method: 'POST',
url: 'http://localhost:8378/1/classes/TestObject',
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest',
'X-Parse-Context': '{"key":"value","otherKey":1}',
},
body: {
foo: 'bar',
},
});

Alternatives / Workarounds

No workarounds for using context in the header. Will have to modify the body with _context like the other SDKs.

3rd Party References

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:releasedReleased as stable versionstate:released-betaReleased as beta versiontype:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions