function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Agnibha Chakrabarti 10Agnibha Chakrabarti 10 

What does RestResponse class do in Apex REST webservice

hi, I'm learning apex Rest web service.
i came across this code
global with sharing class MyRestResource {

    global static void doDelete() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        Account account = [SELECT Id FROM Account WHERE Id = :accountId];
        delete account;

but im not able to understand what does
RestResponse res = RestContext.response;

Can anybody tell what exactly RestResponse do with an example

Devi ChandrikaDevi Chandrika (Salesforce Developers) 
It looks like In this method they are not using RestResponse.Initialized but it is not used anywhere.
RestResponse res = RestContext.response  is not doing anything here.

Usually RestResponse object is used to pass data from an Apex RESTful Web service method to an HTTP response.
Please refer below link which might help you in this

Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.

Thanks and Regards