4d (edited) • Notes 📝
Http and Routing
Day -2 of learning Web Dev
#Backend-Engineering Day-2
First practise some tasks related to http to implement what i have stuided yesterday ,
then studied Routing and here is summary of it :
HTTP is about : WHAT you want to do(PUT,POST,GET,DELETE etc)
→while Routing is about: WHERE you want to do it
→routing is basically mapping URL parameters to a server side logic
→ static routing: address does not change
→But a limitation arises in static routes that we can’t create a separate URL for every user, so the route needs dynamic parts that change based on which user is requested. Here dynamic route come into the field
→Dynamic routes use placeholders like /users/:id so one route can handle unlimited users by reading the actual value (like 92) from the URL and fetching the correct data.
→ Here another point arises that when we need to send extra details like filters or page numbers not a specific identity, we can’t put them in the body because GET requests don’t allow a body, and using path parameters for this would be confusing.
→Query parameters exist to send extra instructions like search, filters, or page numbers in GET requests, because they describe how to get the data, not which data.
→ Nested routes are used to show relationships clearly: for example, users have posts, so /users/123/posts means “all posts of user 123,” and /users/123/posts/456 means “post 456 of user 123.”it makes the URL match real-world relationships.
→ Versioning solves a real problem: when an API changes, it can break existing clients. By adding versions like /api/v1/products and /api/v2/products, old clients keep working, new clients can use the updated API, and you can safely update or deprecate features without breaking anything.
→ Catch-all routes handle any URL the server doesn’t recognize, so instead of confusing behavior or errors, the server responds with “Route not found,” making the API predictable, user-friendly, and easier to debug.
1
0 comments
Shoaib Khan
2
Http and Routing
powered by
Make $1k-$10k in 30 days
skool.com/make-1k-5k-in-30-days-8449
Media Valley School is the fastest way to hit $1K/month with freelancing or agency work. Guaranteed.
Land your first $1K month in 30 days
Build your own community
Bring people together around your passion and get paid.
Powered by