Lahat ng language at framework
Azure Functions (Node.js v4 model) JavaScript
Isang JavaScript snippet para sa Azure Functions (Node.js v4 model) na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.
Azure Functions (Node.js v4 model) JavaScript
// src/functions/pixel.js
import { app } from '@azure/functions';
const GIF = Buffer.from('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', 'base64');
app.http('pixel', {
methods: ['GET'],
authLevel: 'anonymous',
// Routes have no leading slash and sit under the "api" prefix unless
// extensions.http.routePrefix is set to "" in host.json.
route: '/pixel.gif'.slice(1),
handler: async () => ({
body: GIF,
headers: {
'Content-Type': 'image/gif',
'Content-Length': String(GIF.length),
'Cache-Control': 'no-store',
},
}),
});
Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.
Suriin
curl -sI http://localhost:8080/pixel.gif
Opisyal na site: Azure Functions (Node.js v4 model)