catch function mapping overwriting existing endpoint
Open
Nobody has claimed this yet.
improvement
- Dominant language
- Python
- Stars
- 838
- Forks
- 123
- Avg merge
- 7h 58m
- Merged PRs (30d)
- 12
Description
The most common error I run into when rapidly making a little klein app is when I accidentally overwrite a function when I copy an existing route or accidentally name it the same, could we catch this like in Flask?
@route('/')
def home(request):
return 'Hello, world!'
@route('/foobar')
def home(request):
return 'Hello, foobar!'
run("localhost", 8080)
[-] Site starting on 8080
vs
app = Flask(__name__)
@app.route("/")
def home():
return "Hello World!"
@app.route('/foobar')
def home():
return 'Hello, foobar!'
if __name__ == "__main__":
app.run()
AssertionError: View function mapping is overwriting an existing endpoint function: home
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names Klein's @route decorator and run() entry point but no files or tests. Reproduce the two snippets, then trace how route functions are registered; done means duplicate endpoint names are reported at startup while distinct endpoint names continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100