Swift Question

[Problem 1] Ktor REST Server

You will create a Ktor REST server. The server listens to port 8888 and implements a service that will perform a mathematical addition operation on two input numbers (sent with the POST method). It adds two numbers and returns the sum via the response message.

The specification of the service is summarized in the following table.

Service Name

HTTP Request

HTTP Response

Method

Parameters

Format

Data

Format

Data

/MathService/add

POST

JSON

Two operands (of Float type)

Plain Text

The sum of two operands

[Problem 2] Fuel REST Client

You will implement an ios application to test the Service created in Problem 1. Please following the following steps for your implementation.

  1. Implement a Kotlin class named MathService where you define

    • A property named result (of Float type)

    • A method named add which takes two Float numbers as input parameters

  1. The add(…) method will perform the following logic:

    • Use Fuel API to submit a REST /MathService/add request

    • Convert the data returned from the service to a Float object and assign it to the result property

SAMPLE ASSIGNMENT
Powered by WordPress