Page 107 - Yazılım Teknolojileri Araştırma Bülteni 2023
P. 107

RapidRows: Postgres için Kolay API Server | 107





                  $sys.params.rental_id)
              params:
              - name: rental_id
                in: body
                type: integer
                minimum: 1

                required: true
            datasources:
            - name: pagila
              dbname: pagila



           Yukarıda tanımlanmış örneğin kullanımı ve çıktısı aşağıdaki gibidir:



            curl -i -X POST http:-/localhost:8080/exec-js -H ‘Content-Type: application/
            json’ -d ‘{ “rental_id”: 3 }’
            HTTP/1.1 204 No Content
            Date: Wed, 21 Sep 2022 06:07:17 GMT


           Eğer olmayan bir rental_id gönderilirse:



            curl -i -X POST http:-/localhost:8080/exec-js -H ‘Content-Type: application/
            json’ -d ‘{ “rental_id”: 17000 }’

            HTTP/1.1 500 Internal Server Error
            Content-Type: text/plain; charset=utf8
            Date: Wed, 21 Sep 2022 06:07:24 GMT
            Content-Length: 16

            Rental not found



           Yukarıdaki kod bloğunda belirli bir içerik türüne göre farklı hata üretilmesi istenirse:



            $ curl -i -X POST http:-/localhost:8080/exec-js -H ‘Content-Type: application/
            json’ -d ‘{ “rental_id”: 4 }’
            HTTP/1.1 500 Internal Server Error
            Content-Type: text/plain; charset=utf8
            Date: Wed, 21 Sep 2022 06:07:14 GMT
            Content-Length: 40


            Cannot return Horror DVDs on Wednesdays!
   102   103   104   105   106   107   108   109   110   111   112