Histórico da Página
Esta annotation deve ser utilizada quando for necessário desenvolver uma aplicação que responderá pelo método/verbo PUT. Este método/verbo substitui todas as atuais representações do recurso de destino pela carga de dados da requisição.
Abaixo veremos exemplos de sua utilização:
Exemplo utilizando função e recebendo parâmetro via path param
/* --------------------------------------- */
@Put("examples/function/put/path/user/:user")
User Function examplesFunctionPutPath()
Local cJson := ""
Local jPath
Local cBody := ""
jPath := JsonObject():New()
jPath := oRest:getPathParamsRequest()
cBody := oRest:getBodyRequest()
If (jPath <> Nil)
cJson := '[ { "description": "examplesFunctionPutPath successfully executed, parameter received: ' + jPath['user'] + '" , "body received":"'+ cBody + '"} ]'
Endif
Return oRest:setResponse(cJson)
Exemplo utilizando função recebendo parâmetro via query string
/* --------------------------------------- */
@Put("examples/function/put/query/user")
User Function examplesFunctionPutQuery()
Local cJson := ""
Local cBody := ""
Local jQuery
jQuery := JsonObject():New()
jQuery := oRest:getQueryRequest()
cBody := oRest:getBodyRequest()
If (jQuery <> Nil)
cJson := '[ {"description": "examplesFunctionPutQuery successfully executed, parameter received: ' + jQuery['user'] + '" , "body received":"'+ cBody + '"} ]'
Endif
Return oRest:setResponse(cJson)
Class classPutExamples
Public Method New()
@Put("examples/class/put/path/user/:user")
Public Method methodExamplesPutPath()
@Put("examples/class/put/query/user")
Public Method methodExamplesPutQuery()
EndClass
Method New() class classPutExamples
Return self
/* --------------------------------------- */
Method methodExamplesPutPath() class classPutExamples
Local cJson := ""
Local cBody := ""
Local jPath
jPath := JsonObject():New()
jPath := oRest:getPathParamsRequest()
cBody := oRest:getBodyRequest()
If (jPath <> Nil)
cJson := '[ {"description": "examplesMethodPutPath successfully executed, parameter received: ' + jPath['user'] + '" , "body received":"'+ cBody + '"} ]'
Endif
Return oRest:setResponse(cJson)
/* --------------------------------------- */
Method methodExamplesPutQuery() class classPutExamples
Local cJson := ""
Local cBody := ""
Local jQuery
jQuery := JsonObject():New()
jQuery := oRest:getQueryRequest()
cBody := oRest:getBodyRequest()
If (jQuery <> Nil)
cJson := '[ {"description": "examplesMethodPutQuery successfully executed, parameter received: ' + jQuery['user'] + '" , "body received":"'+ cBody + '"} ]'
Endif
Return oRest:setResponse(cJson)
Incluir Página | ||||
---|---|---|---|---|
|
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas