coldfusion
कोल्ड फ्यूजन में रीस्ट एपीआई बनाना
खोज…
परिचय
REST API तब दिलचस्प होता है जब विभिन्न भाषाओं (सर्वर और क्लाइंट साइड) सहित हर जगह से डेटा एक्सेस किया जाना चाहिए। इसके लिए डेटा और प्रोसेसिंग से अलग होना आवश्यक है।
बैकएंड बनाना
<cfcomponent displayname="myAPI" output="false">
<cffunction name="init" access="public" output="no">
<!--- do some basic stuff --->
<cfreturn this>
</cffunction>
<cffunction name="welcome">
<cfreturn "Hello World!">
</cffunction>
</cfcomponent>
अंतरपटल
<cfscript>
api_request = GetHttpRequestData();
api = createObject("component","myAPI").init();
</cfscript>
<cfif api_request.method is 'GET'>
<cfoutput>#api.welcome()#</cfoutput>
<cfelseif api_request.method is 'POST'>
<cfheader statuscode="500" statustext="Internal Server Error" />
</cfif>
Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow