webdev-20 / shorti-url-shortener

Url Shortener
http://shorti.onrender.com/
7 stars 18 forks source link

add endpoint to redirect user from short code to original URL #40

Closed cherylli closed 2 years ago

cherylli commented 2 years ago

Summary

Add endpoint to redirect user from short code to original url closes #32

  1. create a new link

    POST http://localhost:4002/api/links Content-Type: application/json

{ "url": "https://www.google.com/search?q=javascript&rlz=1C1CHBF_en-GBAU898AU898&sxsrf=ALiCzsZsxzU9mEq1tD9NbJDwm_X_xU9Vrw%3A1664719017794&ei=qZg5Y6eQMNiFmAXuzoiQDA&ved=0ahUKEwjniNPN2cH6AhXYAqYKHW4nAsIQ4dUDCA4&uact=5&oq=javascript&gs_lcp=Cgdnd3Mtd2l6EAMyBAgjECcyBAgjECcyBAgjECcyBwgAELEDEEMyCwguEIAEEMcBEK8BMggIABCABBCxAzIFCAAQgAQyCAgAEIAEELEDMggIABCABBCxAzILCAAQgAQQsQMQgwE6BwgjELADECc6CggAEEcQ1gQQsAM6BwgAELADEEM6DAguEMgDELADEEMYAToPCC4Q1AIQyAMQsAMQQxgBOgUIABCRAjoRCC4QgAQQsQMQgwEQxwEQ0QM6CwguELEDEIMBENQCOggILhCxAxCDAToOCC4QgAQQsQMQxwEQ0QM6BAguEEM6BAgAEEM6CgguELEDEIMBEEM6CggAELEDEIMBEEM6CggAEIAEEIcCEBQ6BwguELEDEEM6DgguEIAEELEDEIMBENQCSgQIQRgASgQIRhgBUL0aWNYiYKclaAFwAXgAgAHaAYgBzQySAQUwLjcuMpgBAKABAcgBEsABAdoBBggBEAEYCA&sclient=gws-wiz" }

for example if the short code returned is elwtr

entering http://localhost:4002/api/links/elwtr in the browser address bar will redirect user to the really long url