Esta annotation deve ser utilizada quando for necessário desenvolver uma aplicação que responderá pelo método/verbo POST. Este método/verbo
Abaixo veremos exemplos de sua utilização:
Exemplo utilizando função e recebendo parâmetro via path param
/* ----------------------------------------- */
@Post("examples/function/post/path/user/:user")
User Function examplesFunctionPostPath()
Local cJson := ""
Local jPath
Local cBody := ""
jPath := JsonObject():New()
jPath := oRest:getPathParamsRequest()
cBody := oRest:getBodyRequest()
If (jPath <> Nil)
cJson := '[ { "description": "examplesFunctionPostPath 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
/* ----------------------------------------- */
@Post("examples/function/post/query/user")
User Function examplesFunctionPostQuery()
Local cJson := ""
Local cBody := ""
Local jQuery
jQuery := JsonObject():New()
jQuery := oRest:getQueryRequest()
cBody := oRest:getBodyRequest()
If (jQuery <> Nil)
cJson := '[ {"description": "examplesFunctionPostQuery 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 classPostExamples
Public Method New()
Public Method methodExamplePostPath()
Public Method methodExamplePosthQuery()
EndClass
Method New() class classPostExamples
Return self
/* ----------------------------------------- */
@Post("examples/class/post/path/user/:user")
Method methodExamplesPostPath() class classPostExamples
Local cJson := ""
Local cBody := ""
Local jPath
jPath := JsonObject():New()
jPath := oRest:getPathParamsRequest()
cBody := oRest:getBodyRequest()
If (jPath <> Nil)
cJson := '[ {"description": "examplesMethodPostPath successfully executed, parameter received: ' + jPath['user'] + '" , "body received":"'+ cBody + '"} ]'
Endif
Return oRest:setResponse(cJson)
/* ----------------------------------------- */
@Post("examples/class/post/query/user")
Method methodExamplesPostQuery() class classPostExamples
Local cJson := ""
Local cBody := ""
Local jQuery
jQuery := JsonObject():New()
jQuery := oRest:getQueryRequest()
cBody := oRest:getBodyRequest()
If (jQuery <> Nil)
cJson := '[ {"description": "examplesMethodPostQuery successfully executed, parameter received: ' + jQuery['user'] + '" , "body received":"'+ cBody + '"} ]'
Endif
Return oRest:setResponse(cJson)
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas