Esta annotation deve ser utilizada quando for necessário desenvolver uma aplicação que responderá pelo método/verbo GET. Este método/verbo solicita uma representação do recurso especificado na Uri. Abaixo veremos exemplos de sua utilização:
Exemplo utilizando função e recebendo parâmetro via path param
/* --------------------------------------- */
@Get("examples/function/get/path/user/:user")
User Function examplesFunctionGetPath()
Local cJson := ""
Local jPath
jPath := JsonObject():New()
jPath := oRest:getPathParamsRequest()
If (jPath <> Nil)
cJson := '[ { "description": "functionExamplesGetPath successfully executed, parameter received: ' + jPath['user'] +'"} ]'
Endif
Return oRest:setResponse(cJson)
Exemplo utilizando função e recebendo parâmetro via query string
/* --------------------------------------- */
@Get("examples/function/get/query/user")
User Function examplesFunctionGetQuery()
Local cJson := ""
Local jQuery
jQuery := JsonObject():New()
jQuery := oRest:getQueryRequest()
If (jQuery <> Nil)
cJson := '[ {"description": "examplesFunctionGetQuery successfully executed, parameter received: ' + jQuery['user'] + '"} ]'
Endif
Return oRest:setResponse(cJson)
Class classGetExamples
Public Method New()
Public Method metodExamplesGetPath()
Public Method metodExamplesGetQuery()
EndClass
Method New() class classGetExamples
Return self
/* --------------------------------------- */
@Get("examples/class/get/path/user/:user")
Method methodExamplesGetPath() class classGetExamples
Local cJson := ""
Local jPath
jPath := JsonObject():New()
jPath := oRest:getPathParamsRequest()
If (jPath <> Nil)
cJson := '[ {"description": "methodExamplesGetPath successfully executed, parameter received: ' + jPath['user'] + '"} ]'
Endif
Return oRest:setResponse(cJson)
/* --------------------------------------- */
@Get("examples/class/get/query/user")
Method methodExamplesGetQuery() class classGetExamples
Local cJson := ""
Local jQuery
jQuery := JsonObject():New()
jQuery := oRest:getQueryRequest()
If (jQuery <> Nil)
cJson := '[ {"description": "methodExamplesGetQuery successfully executed, parameter received: ' + jQuery['user'] + '"} ]'
Endif
Return oRest:setResponse(cJson)
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas