Histórico da Página
Esta annotation deve ser utilizada quando for necessário desenvolver uma aplicação que responderá pelo método/verbo PATCH. Este método/verbo aplica modificações parciais a um recurso.
Exemplo utilizando função e recebendo parâmetro via path param
/* ------------------------------------------- */
@Patch("examples/function/patch/path/user/:user")
User Function examplesFunctionPatchPath()
Local cJson := ""
Local jPath
Local cBody := ""
jPath := JsonObject():New()
jPath := oRest:getPathParamsRequest()
cBody := oRest:getBodyRequest()
If (jPath <> Nil)
cJson := '[ { "description": "examplesFunctionPatchPath successfully executed, parameter received: ' + jPath['user'] + '" , "body received":"'+ cBody + '"} ]'
Endif
Return oRest:setResponse(cJson)
Exemplo utilizando função e recebendo parâmetro via query string
/* ------------------------------------------- */
@Patch("examples/function/patch/query/user")
User Function examplesFunctionPatchQuery()
Local cJson := ""
Local cBody := ""
Local jQuery
jQuery := JsonObject():New()
jQuery := oRest:getQueryRequest()
cBody := oRest:getBodyRequest()
If (jQuery <> Nil)
cJson := '[ {"description": "examplesFunctionPatchQuery successfully executed, parameter received: ' + jQuery['user'] + '" , "body received":"'+ cBody + '"} ]'
Endif
Return oRest:setResponse(cJson)
Exemplo utilizando classe com métodos recebendo parâmetro via path param e query string.
Class classPatchExamples
Public Method New()
@Patch("examples/class/patch/path/user/:user")
Public Method methodExamplePatchPath()
@Patch("examples/class/patch/query/user")
Public Method methodExamplePatchQuery()
EndClass
Method New() class classPatchExamples
Return self
/* ------------------------------------------- */
Method methodExamplesPatchPath() class classPatchExamples
Local cJson := ""
Local cBody := ""
Local jPath
jPath := JsonObject():New()
jPath := oRest:getPathParamsRequest()
cBody := oRest:getBodyRequest()
If (jPath <> Nil)
cJson := '[ {"description": "examplesMethodPatchPath successfully executed, parameter received: ' + jPath['user'] + '" , "body received":"'+ cBody + '"} ]'
Endif
Return oRest:setResponse(cJson)
/* ------------------------------------------- */
Method methodExamplesPatchQuery() class classPatchExamples
Local cJson := ""
Local cBody := ""
Local jQuery
jQuery := JsonObject():New()
jQuery := oRest:getQueryRequest()
cBody := oRest:getBodyRequest()
If (jQuery <> Nil)
cJson := '[ {"description": "examplesMethodPatchQuery 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