How to rate limit end point?

Generally how do people rate limit endpoints? Do you use a library or use your own code?