Files
svc-api-x/v1/taffy/examples/api_requireApiKey/Application.cfc
2024-10-23 11:17:42 +03:00

20 lines
502 B
Plaintext

<cfcomponent extends="taffy.core.api">
<cfscript>
this.name = hash(getCurrentTemplatePath());
// this function is called after the request has been parsed and all request details are known
function onTaffyRequest(verb, cfc, requestArguments, mimeExt){
if(not structKeyExists(arguments.requestArguments, "apiKey")){
//unauthorized because they haven't included their API key
return noData().withStatus(401);
}
//api key found
return true;
}
</cfscript>
</cfcomponent>