You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enables server to error out on "deprecated" version of the schema
Very helpful for debugging HTTP 400 errors (missing fields, renamed fields etc.)
Go server
Let's add a helper function to help parse the schema version easily.
funcGetClientHeader(r*http.Request) (schemastring, webrpcstring, genstring) {
// value of header or ""
}
funcParseVersion(r*http.Request) (major, minor, bugfixint) {
// parse X-Webrpc-Client header and return the details of the schema version// returns 0, 0, 0 if header is missing
}
Adding a new header to all requests might lead to CORS errors unless the server whitelists the new header. So perhaps we should make this an opt-in feature for now. However, I'd greatly support making this field mandatory as part of "webrpc protocol standard" down the road. Maybe we can make this an opt-out feature after a few releases. Or maybe we can enforce it in the generated client initialization - a new required field when you instantiate the client. Thoughts?
The text was updated successfully, but these errors were encountered:
I tried to look up the naming convention for headers, and it looks like, the use of X- prefix is not recommended anymore.
Check this https://www.rfc-editor.org/rfc/rfc6648
This can be ignored it and just use X-Webrpc-Client instead of Webrpc-Client.
Second
I would change the structure from this: X-Webrpc-Client: {serviceName}@{schemaVersion}; webrpc@{webrpcGenVersion}; github.com/webrpc/gen-golang@{templateVersion}
To this: X-Webrpc-Client: service={serviceName}@{schemaVersion}; webrpc-verison={webrpcGenVersion}; template={template-source}@{templateVersion}
I propose to add a new
X-Webrpc-Client
header to all webrpc client requests:Example:
Potential use-cases from the server perspective:
Go server
Let's add a helper function to help parse the schema version easily.
BREAKING CHANGE?
Adding a new header to all requests might lead to CORS errors unless the server whitelists the new header. So perhaps we should make this an opt-in feature for now. However, I'd greatly support making this field mandatory as part of "webrpc protocol standard" down the road. Maybe we can make this an opt-out feature after a few releases. Or maybe we can enforce it in the generated client initialization - a new required field when you instantiate the client. Thoughts?
The text was updated successfully, but these errors were encountered: