Implement the function drainHTTPRequestBody(req *http.Request) ([]byte, error) in the /app/ directory. This function should accomplish the following:
Draining Logic: It should read and drain the entire body of the provided HTTP request (req) and return it as a byte slice. If the body has already been drained, subsequent calls should return an empty byte slice.
Error Handling:
If the request body is nil, the function should return nil and the error io.EOF.
For any other errors encountered while reading the body, these errors should be returned as-is.
Multiple Reads: The function should correctly handle multiple calls to drain the same request object, meaning that after the first call, subsequent calls should return an empty slice and no error if the body has been completely read.
Ensure that your implementation passes the following tests provided in the test code:
TestDrainHTTPRequestBody: Verifies that the body is correctly drained multiple times.
TestDrainHTTPRequestBodyNil: Ensures that a nil body returns the correct error and nil slice.
Place your implementation in a file named http_body_drainer.go inside the /app/ directory.
Important: declare your solution in package schema (the test file uses package schema, so the implementation must use the matching package name).