File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
npm-packages/docs/docs/functions Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,22 @@ import Fetch from "!!raw-loader!@site/../private-demos/snippets/src/httpAuthCall
1212
1313HTTP actions allow you to build an HTTP API right in Convex!
1414
15+ ``` ts title="convex/http.ts"
16+ import { httpRouter } from " convex/server" ;
17+ import { httpAction } from " ./_generated/server" ;
18+
19+ const http = httpRouter ();
20+
21+ http .route ({
22+ path: " /" ,
23+ method: " GET" ,
24+ handler: httpAction (async (ctx , request ) => {
25+ return new Response (` Hello from ${request .url } ` );
26+ }),
27+ });
28+ export default http ;
29+ ```
30+
1531HTTP actions take in a
1632[ Request] ( https://developer.mozilla.org/en-US/docs/Web/API/Request ) and return a
1733[ Response] ( https://developer.mozilla.org/en-US/docs/Web/API/Response ) following
@@ -70,7 +86,7 @@ Here's an example:
7086</>
7187
7288<TSAndJSSnippet
73- title = " convex/http.js "
89+ title = " convex/http.ts "
7490 sourceTS = { http }
7591 sourceJS = { http }
7692 snippet = " router"
You can’t perform that action at this time.
0 commit comments