diff --git a/content/_redirects b/content/_redirects index a34eefabdb3405204d63fc580cb7abecbd57886d..4a516d776d6854382bed609ccd6f474a560a3383 100644 --- a/content/_redirects +++ b/content/_redirects @@ -405,6 +405,7 @@ /pages/how-to/elderjs/ /pages/framework-guides/elderjs/ 301 /pages/platform/github-integration/ /pages/platform/git-integration/ 301 /pages/platform/direct-uploads/ /pages/platform/direct-upload/ 301 +/platform/functions/billing/ /platform/functions/pricing/ 301 # partners /partners/ /learning-paths/technology-partner-integrations/ 301 diff --git a/content/pages/platform/functions/api-reference.md b/content/pages/platform/functions/api-reference.md index 7e52a531d858ca1f5fa6c7583198f6182a91ceaf..1cab5abfc3b425adc260c7ff1b8fe46b5746c990 100644 --- a/content/pages/platform/functions/api-reference.md +++ b/content/pages/platform/functions/api-reference.md @@ -2,4 +2,64 @@ pcx-content-type: how-to title: API Reference weight: 3 ---- \ No newline at end of file +--- + +The following APIs are used within Functions. + +## Methods + +<Some text about these> + +### onRequests + +{{<definitions>}} + +- {{<code>}}onRequest(context[{{<param-type>}}EventContext{{</param-type>}}](#eventcontext)){{</code>}} {{<type>}}Response | Promise<Response>{{</type>}} + - This function will be invoked on all requests no matter the request method +- {{<code>}}onRequestGet(context[{{<param-type>}}EventContext{{</param-type>}}](#eventcontext)){{</code>}} {{<type>}}Response | Promise<Response>{{</type>}} + - This function will be invoked on all GET requests +- {{<code>}}onRequestPost(context[{{<param-type>}}EventContext{{</param-type>}}](#eventcontext)){{</code>}} {{<type>}}Response | Promise<Response>{{</type>}} + - This function will be invoked on all POST requests +- {{<code>}}onRequestPatch(context[{{<param-type>}}EventContext{{</param-type>}}](#eventcontext)){{</code>}} {{<type>}}Response | Promise<Response>{{</type>}} + - This function will be invoked on all PATCH requests +- {{<code>}}onRequestPut(context[{{<param-type>}}EventContext{{</param-type>}}](#eventcontext)){{</code>}} {{<type>}}Response | Promise<Response>{{</type>}} + - This function will be invoked on all PUT requests +- {{<code>}}onRequestDelete(context[{{<param-type>}}EventContext{{</param-type>}}](#eventcontext)){{</code>}} {{<type>}}Response | Promise<Response>{{</type>}} + - This function will be invoked on all DELETE requests +- {{<code>}}onRequestHead(context[{{<param-type>}}EventContext{{</param-type>}}](#eventcontext)){{</code>}} {{<type>}}Response | Promise<Response>{{</type>}} + - This function will be invoked on all HEAD requests +- {{<code>}}onRequestOptions(context[{{<param-type>}}EventContext{{</param-type>}}](#eventcontext)){{</code>}} {{<type>}}Response | Promise<Response>{{</type>}} + - This function will be invoked on all OPTIONS requests + +{{</definitions>}} + +### env.ASSETS.fetch() + +The env.ASSETS.fetch() function allows you to fetch a static asset. Requests to this will be to the pretty path not directly to the asset (i.e. if you had the path: `functions/users/index.html`, you will request /users/ instead of /users/index.html). This will run the header and redirect rules, so they will modify the response that is returned. + +## Types + +### EventContext + +{{<definitions>}} +The following are the properties on the context object which are passed through on the onRequest methods: + + - `request` [{{<type>}}Request{{</type>}}](/workers/runtime-apis/request/) + + This is the incoming [Request](/workers/runtime-apis/request/). + + - `functionPath` {{<type>}}string{{</type>}} + - {{<code>}}waitUntil(promise{{<param-type>}}Promise<any>{{</param-type>}}){{</code>}} {{<type>}}void{{</type>}} + - {{<code>}}passThroughOnException(){{</code>}} {{<type>}}void{{</type>}} + - {{<code>}}next(input?{{<param-type>}}Request | string{{</param-type>}}, init?{{<param-type>}}RequestInit{{</param-type>}}){{</code>}} {{<type>}}Promise<Response>{{</type>}} + - `env` [{{<type>}}EnvWithFetch{{</type>}}](#envwithfetch) + - `param` [{{<type>}}Params<P>{{</type>}}](#params) + - `data` [{{<type>}}Data{{</type>}}](#data) + +{{</definitions>}} + +### EnvWithFetch + +### Params + +### Data \ No newline at end of file