question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API design question - `Response.url`

See original GitHub issue

Currently our Response.url attribute exposes a URL instance.

This is a breaking change from the requests API where it just exposes a plain string.

It’s feasible that we should instead only be exposing plain string URLs, in order to aim for drop-in replacement API compatibility w/ requests, and in order to keep the API surface area low.

Options here are:

  • Expose request.url as a URL instance. (Richer information, URL class is also useful in its own right.)
  • Expose request.url as a str. (Better API compat. Lower API surface area to maintain.)
  • Expose request.url as a str, and request.urlinfo as a URL instance. (Better API compat. High API surface area.)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
tomchristiecommented, Jul 9, 2019

If we do keep it as a URL instance, then one option to keep closer API compat would be to allow string comparisons, eg URL(“https://www.encode.io/“) == “https://www.encode.io/“

That has the advantage of being string-like, and far less likely to introduce any API breakage.

1reaction
tomchristiecommented, Jul 9, 2019

Seems like it’s probably the best all round option yeah.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best practices for REST API design - Stack Overflow Blog
Learn how to design REST APIs to be easy to understand for anyone, future-proof, secure, and fast since they serve data to clients...
Read more >
Answers To The Most Common REST API Interview Questions
The most commonly asked REST API interview questions to prep for system design, software engineering, and other technical interviews.
Read more >
Best Practices for Designing a Pragmatic RESTful API
An API is a user interface for a developer. Learn the best practices to make an API that is easy to adopt and...
Read more >
Top REST API Interview Questions and Answers (2023)
REST is based on the Request-Response Model. Web Socket follows the full-duplex model. Every request will have sections like header, title, body, URL,...
Read more >
13 API Design Interview Questions to Ask Developers ... - Twine
This article will cover some of the more common API Design interview questions, paired with some top-notch answers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found