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
CCF provides the additional global variable ``ccf`` to access native CCF functionality.
116
+
It is an object implementing the :js:class:`CCF <CCF>` interface documented below.
124
117
125
118
.. note::
126
119
`Web APIs <https://developer.mozilla.org/en-US/docs/Web/API>`_ are not available.
127
120
121
+
.. js:autoclass::CCF
122
+
:members:
123
+
124
+
.. js:autoclass:: KVMap
125
+
:members:
126
+
127
+
.. js:autoclass:: WrapAlgoParams
128
+
:members:
129
+
130
+
.. js:autoclass:: RsaOaepParams
131
+
:members:
132
+
133
+
.. js:autoclass:: AESKWPParams
134
+
:members:
135
+
136
+
.. js:autoclass:: RsaOaepAESKWPParams
137
+
:members:
138
+
139
+
.. js:autoclass:: CryptoKeyPair
140
+
:members:
141
+
128
142
Endpoint handlers
129
143
~~~~~~~~~~~~~~~~~
130
144
131
-
An endpoint handler is an exported function that receives a ``Request`` object, returns a ``Response`` object,
132
-
and is referenced in the ``app.json`` file of the app bundle (see above).
133
-
134
-
A ``Request`` object has the following fields:
135
-
136
-
- ``headers``: An object mapping lower-case HTTP header names to their values.
137
-
- ``params``: An object mapping URL path parameter names to their values.
138
-
- ``query``: The query string of the requested URL.
139
-
- ``body``: An object with ``text()``/``json()``/``arrayBuffer()`` functions to access the
140
-
request body in various ways.
141
-
- ``caller``: An object describing the authenticated identity retrieved by this endpoint's authentication policies.
142
-
``caller.policy`` is a string indicating which policy accepted this request, for use when multiple policies are
143
-
listed. The other fields depend on which policy accepted; most set ``caller.id``, ``caller.data``, and ``caller.cert``,
144
-
while the ``"jwt"`` policy sets ``caller.jwt``.
145
-
146
-
A ``Response`` object can contain the following fields (all optional):
147
-
148
-
- ``statusCode``: The HTTP status code to return (default ``200``, or ``500`` if an exception is raised).
149
-
- ``headers``: An object mapping lower-case HTTP header names to their values.
150
-
The type of ``body`` determines the default value of the ``content-type`` header, see below.
151
-
- ``body``: Either
152
-
a `string <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String>`_ (``text/plain``),
153
-
an `ArrayBuffer <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer>`_ (``application/octet-stream``),
154
-
a `TypedArray <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray>`_ (``application/octet-stream``),
155
-
or as fall-back any `JSON-serializable <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify>`_ value (``application/json``).
156
-
The content type in parentheses is the default and can be overridden in ``headers``.
145
+
An endpoint handler is an exported function that receives a :js:class:`Request <Request>` object, returns a :js:class:`Response <Response>` object, and is referenced in the ``app.json`` file of the app bundle (see above).
146
+
147
+
.. js:autoclass:: Request
148
+
:members:
149
+
150
+
.. js:autoclass:: Response
151
+
:members:
157
152
158
153
See the following handler from the example app bundle in the
Using CCF's ``Response`` object is not needed when using tsoa because the return value always has to be the body itself.
117
+
Using CCF's :js:class:`Response` object is not needed when using tsoa because the return value always has to be the body itself.
116
118
Headers and the status code can be set using `Controller methods <https://tsoa-community.github.io/reference/classes/_tsoa_runtime.controller-1.html>`_.
117
119
118
-
Sometimes though it is necessary to access CCF's ``Request`` object, for example when the request body is not JSON.
119
-
In this case, instead of using ``@Body() body: MyType`` as function argument, ``@Request() request: ccf.Request`` can be used.
120
+
Sometimes though it is necessary to access CCF's :js:class:`Request` object, for example when the request body is not JSON.
121
+
In this case, instead of using ``@Body() body: MyType`` as function argument, ``@Request() request: CCF.Request`` can be used.
120
122
See `src/controllers/csv.ts <https://github.com/microsoft/CCF/tree/main/samples/apps/forum/src/controllers/csv.ts>`_
121
123
for a concrete example.
122
124
123
125
.. warning::
124
-
Requesting CCF's ``Request`` object via ``@Request()`` instead of using ``@Body()`` disables automatic schema validation.
126
+
Requesting CCF's :js:class:`Request` object via ``@Request()`` instead of using ``@Body()`` disables automatic schema validation.
0 commit comments