I did something i deeply regret

I've never posted here, but I just need to let this out.

So, recently my 5 year old has been a real pain to put to bed every single night. He usually starts joking around when it is time for bed, but i have remained calm and patient every night (this has been going on every single night for the last 2 months).

Yesterday when going through our usual struggle, he started spitting at me. I explained to him why it was wrong and why he shouldn't do that. He kept going, but eventually i got through to him and calmed him down.

So today we were at it again. After a bit of struggle he did it again. No matter what i said he just kept going. I tried to keep him on my lap and calm him down, but he just kept spitting and spitting no matter what i said. Eventually all the built up frustration hit me and i snapped and spat back at him. I immediately regretted it and washed his face and apologized. I explained to him that it was not ok to do what i just did, and that neither me or him should ever do it again.

I am disgusted by myself. I did something i never could imagine myself doing. I feel like the worlds worst parent, as i probably should.. just needed to get this off my chest

EDIT: I just want to make clear, he has never spitted at me before, this started yesterday

EDIT: Thank you for all the replies, I did not expect such a response! It makes me feel better being met with understanding. And just to clarify: I’m a dad not a mom (not that I think it should matter). My son became a big brother a few weeks back, and although we try to give him all the attention we can, I still suspect it might have something to do with him acting up more than usual (and also with me snapping lol).