Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

...

#include "tlpp-core.th"
#include "tlpp-rest.th"

Class classPostExamples

   Public Method New()
   
   @Post("examples/class/post/path/user/:user")
Public
Method methodExamplePostPath()

   @Post("examples/class/post/query/user")
   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)