수색…


소개

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