Skip to content

Parameter [overwrite] is supported when adding a route. #2746

Closed
haok228 wants to merge 3 commits into
sanic-org:mainfrom
haok228:main
Closed

Parameter [overwrite] is supported when adding a route. #2746
haok228 wants to merge 3 commits into
sanic-org:mainfrom
haok228:main

Conversation

@haok228

@haok228 haok228 commented May 3, 2023

Copy link
Copy Markdown
  • addding a route in blueprints
from sanic import Blueprint
from sanic.response import json

v1 = Blueprint(name="Version1", version=1)

@v1.route("/something")
def something(request):
    return json({"my": "something1"})

v2 = v1.copy("Version2", version=2)

# sanic_routing.exceptions.RouteExists: Route already registered: v2/something [GET]
@v2.route("/something", overwrite=True)
def something(request):
    return json({"my": "something2"})

@haok228 haok228 requested a review from a team as a code owner May 3, 2023 14:01
@codecov

codecov Bot commented May 3, 2023

Copy link
Copy Markdown

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (af67801) 88.938% compared to head (e970697) 88.837%.
Report is 34 commits behind head on main.

❗ Current head e970697 differs from pull request most recent head 2a6aefc. Consider uploading reports for the commit 2a6aefc to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##              main     #2746       +/-   ##
=============================================
- Coverage   88.938%   88.837%   -0.101%     
=============================================
  Files           92        92               
  Lines         6952      6961        +9     
  Branches      1185      1189        +4     
=============================================
+ Hits          6183      6184        +1     
- Misses         527       532        +5     
- Partials       242       245        +3     
Files Coverage Δ
sanic/mixins/routes.py 96.694% <100.000%> (+0.027%) ⬆️
sanic/models/futures.py 100.000% <100.000%> (ø)
sanic/router.py 96.039% <100.000%> (+0.039%) ⬆️
sanic/blueprints.py 89.767% <33.333%> (-1.621%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ahopkins

ahopkins commented Jul 9, 2023

Copy link
Copy Markdown
Member

Thanks for the effort on this PR. With the change in #2716, is this still necessary? Are you trying to achieve a different outcome?

bpv2 = bpv1.copy("bp_v2", version=2, allow_route_overwrite=False)

* 'main' of github.com:haok228/sanic:
  Parameter [overwrite] is supported when adding a route. ps: @bp1.route(/abc, overwrite=True)
@ahopkins

ahopkins commented Dec 7, 2023

Copy link
Copy Markdown
Member

I'm closing this because I do not think we need it anymore. If I am wrong, please LMK.

@ahopkins ahopkins closed this Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants