coldfusion
Creazione di API REST in coldfusion
Ricerca…
introduzione
Le API REST sono interessanti quando è necessario accedere ai dati da ovunque, comprese lingue diverse (lato server e lato client). Ciò richiede separazione dai dati e dall'elaborazione.
Creazione back-end
<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>
L'interfaccia
<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
Autorizzato sotto CC BY-SA 3.0
Non affiliato con Stack Overflow