Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.
Incluir PáginaObjetos retornados por referênciaObjetos retornados por referência

Esta annotation deve ser utilizada quando for necessário desenvolver uma aplicação que responderá pelo método/verbo DELETE. Este método/verbo deleta o recurso especificado.Abaixo veremos exemplos de sua utilização:


Exemplo utilizando função e recebendo parâmetro via path param

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

/* --------------------------------------------- */
@Delete("examples/function/delete/path/user/:user")
User Function examplesFunctionDeletePath()
   Local cJson := ""
   Local jPath

   jPath := JsonObject():New()
   jPath := oRest:getPathParamsRequest()

   If (jPath <> Nil)
       cJson := '[ { "description": "examplesFunctionDeletePath successfully executed, parameter received: ' + jPath['user'] +'"} ]'
   Endif
Return oRest:setResponse(cJson)


Exemplo utilizando função recebendo parâmetro via query string

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

/* --------------------------------------------- */
@Delete("examples/function/delete/query/user")
User Function examplesFunctionDeleteQuery()
   Local cJson := ""
   Local jQuery

   jQuery := JsonObject():New()
   jQuery := oRest:getQueryRequest()

   If (jQuery <> Nil)
       cJson := '[ {"description": "examplesFunctionDeleteQuery successfully executed, parameter received: ' + jQuery['user'] + '"} ]'
   Endif
Return oRest:setResponse(cJson)


Exemplo utilizando classe com métodos e recebendo parâmetro via path param e query string.

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

Class classDeleteExamples

   Public Method New()

   @Delete("examples/class/delete/path/user/:user")
   Public Method methodExamplesDeletePath()

   @Delete("examples/class/delete/query/user")
   Public Method methodExamplesDeleteQuery()

EndClass

Method New() class classDeleteExamples

Return self

/* --------------------------------------------- */
Method methodExamplesDeletePath() class classDeleteExamples

   Local cJson := ""
   Local jPath

   jPath := JsonObject():New()
   jPath := oRest:getPathParamsRequest()

   If (jPath <> Nil)
       cJson := '[ {"description": "methodExamplesDeletePath successfully executed, parameter received: ' + jPath['user'] + '"} ]'
   Endif
Return oRest:setResponse(cJson)

/* --------------------------------------------- */
Method methodExamplesDeleteQuery() class classDeleteExamples
   Local cJson := ""
   Local jQuery

   jQuery := JsonObject():New()
   jQuery := oRest:getQueryRequest()

   If (jQuery <> Nil)
       cJson := '[ {"description": "methodExamplesDeleteQuery successfully executed, parameter received: ' + jQuery['user'] + '"} ]'
   Endif
Return oRest:setResponse(cJson)

Incluir Página
Objetos retornados por referência
Objetos retornados por referência