- <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Guide</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/guide/" aria-current="page" class="sidebar-link">Introduction</a></li><li><a href="/guide/getting_started.html" class="sidebar-link">Getting Started</a></li><li><a href="/guide/application.html" class="sidebar-link">Application</a></li><li><a href="/guide/context.html" class="sidebar-link">Context</a></li><li><a href="/guide/request.html" class="sidebar-link">Request</a></li><li><a href="/guide/response.html" class="sidebar-link">Response</a></li><li><a href="/guide/metadata.html" aria-current="page" class="active sidebar-link">Metadata</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/guide/metadata.html#receiving" class="sidebar-link">Receiving</a></li><li class="sidebar-sub-header"><a href="/guide/metadata.html#setting-and-sending" class="sidebar-link">Setting and sending</a></li></ul></li><li><a href="/guide/requests.html" class="sidebar-link">Handling requests</a></li><li><a href="/guide/middleware.html" class="sidebar-link">Middleware</a></li><li><a href="/guide/errors.html" class="sidebar-link">Error Handling</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="metadata"><a href="#metadata" class="header-anchor">#</a> Metadata</h1> <p>Information about a particular gRPC call is can be sent using <a href="https://grpc.io/docs/guides/concepts.html#metadata" target="_blank" rel="noopener noreferrer">metadata<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> in the form of a list of key-value pairs, where the keys are strings and the values are typically strings (but can be binary data). Call calls received in serverces will have a metadata object that was sent by the client. When responding to a call invocation the server can send header metadata, as well additionally status metadata upon completion of the request. Mali adds facilities for working with metadata on top of the core gRPC module.</p> <h2 id="receiving"><a href="#receiving" class="header-anchor">#</a> Receiving</h2> <p>When a request comes into a gRPC call handler, metadata can be accessed via both <code>context</code> and <code>request</code> properties.</p> <p><strong>Example</strong></p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">sayHello</span> <span class="token punctuation">(</span><span class="token parameter">ctx</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
0 commit comments