camera rotation restriction

My question is, if I need to give an example, let’s say I drive in a first-person character, in some games, the camera rotation restriction. I can turn the camera to look left and right, I can turn it 90 degrees. I want to restrict it. How can I do it?