A custom expunge method permanently removes a resource after soft deletion, separating irreversible removal from the standard delete method. It should usually accept any resource, whether or not it is already soft-deleted; requiring two requests adds inconvenience without clear benefit. section 25.2 section 25.3.4
Use a separate expunge operation to keep deletion behavior explicit:
- Keep the standard delete method responsible for marking the resource deleted. section 25.2
- Use expunge for complete removal rather than overloading one method with a permanent-deletion flag. section 25.3.4
- Apply the standard delete method’s referential-integrity rules, such as cascading behavior, consistently where required. section 25.6
Listing 25.7 Definition of the custom expunge method
abstract class ChatRoomApi {
@post("/{id=chatRooms/*}:expunge")
ExpungeChatRoom(req: ExpungeChatRoomRequest): void; #1
}
interface ExpungeChatRoomRequest {
id: string;
}
A ChatRoom API exposes expunging as an explicit POST action on the resource. section 25.3.4
