Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query based routing. #39

Closed
wants to merge 2 commits into from
Closed

Conversation

sarvghotra
Copy link
Contributor

Added a query function to allow query based routing. It takes a dict(String, String) as input for target query.

Following assumptions are made:

  1. request query and target query should be exactly same i.e both should have same key and value pairs.
  2. target query can have empty value for some key for e.g dict("one" => "1", "two" => "") in this case it matches for any value of two but two key must be there in request with some value. (Not sure about this case so need some inputs)

@codecov-io
Copy link

codecov-io commented Mar 10, 2017

Codecov Report

Merging #39 into master will increase coverage by 3.32%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #39      +/-   ##
==========================================
+ Coverage   54.86%   58.19%   +3.32%     
==========================================
  Files           7        7              
  Lines         113      122       +9     
==========================================
+ Hits           62       71       +9     
  Misses         51       51
Impacted Files Coverage Δ
src/routing.jl 79.41% <100%> (+7.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c83c057...83cc3f2. Read the comment docs.

src/routing.jl Outdated
function matchquery(q, req)
qdict = parsequerystring(req[:query])
length(q) != length(qdict) && return false
for pair in q
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (key, value) in ... might be nicer here

@MikeInnes
Copy link
Collaborator

A good idea and a good pr! Just a couple comments to look at.

src/routing.jl Outdated
@@ -19,6 +19,7 @@ function matchpath(target, path)
params = d()
for i = 1:length(target)
if startswith(target[i], ":")
params = d()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for?

@sarvghotra
Copy link
Contributor Author

Fixed the problems that you pointed out, thank you. Is there a problem if it didn't pass the Travis CI build for Julia-0.5 and 0.4 version ?
@MikeInnes

@sarvghotra
Copy link
Contributor Author

@MikeInnes This will help me to prove my understanding of the Mux project for the GSoC. So could you please review the updated (fixed the problems that you pointed) PR soon?

Also, Is it OK if it doesn't pass the Travis CI build for Julia 0.5 and 0.4 version ?

amellnik pushed a commit to amellnik/Mux.jl that referenced this pull request Apr 17, 2018
amellnik pushed a commit to amellnik/Mux.jl that referenced this pull request Apr 17, 2018
# Query routing

function matchquery(q, req)
qdict = parsequerystring(req[:query])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to see if I can rebase this PR on top of master, but this one call parsequerystring doesn't exist, and I'm having trouble locating it in the git history. Does anyone know what this function is supposed to do? @sarvjeetsinghghotra @MikeInnes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpsamaroo
Copy link
Collaborator

So this PR is going to require adding a dependency on HttpCommon; are we okay with that? It needs URIParser and Nullables. If so, we should just be able to rebase this on top of Mux master (not sure if that's what Avik's second commit is doing or if it's just a merge) and then add in the necessary REQUIRE lines and using statements, then this PR should function just fine. I'm testing that out and will report back if I run into any issues.

@hustf
Copy link

hustf commented Feb 6, 2019

I think functionality like parsequerystring belong in an optional utilty package like HttpCommon. Moving "everything" to Http.jl is a way to facilitate making some larger structure changes which were necessary. But this will be hard to maintain in one package over time since too few people know everything. That said, have you checked if similar functionality now exists in Http.jl?

@aviks
Copy link
Member

aviks commented Feb 6, 2019

No, we cannot take dependency on HTTPCommon, that package is effectively deprecated. There should be equivalent functionality in HTTP.jl

To @hustf's point, that may be the case eventually, but for now everything in HTTP.jl is simpler to maintain.

@aviks
Copy link
Member

aviks commented Feb 6, 2019

https://github.com/JuliaWeb/HTTP.jl/blob/master/src/URIs.jl#L287

aviks added a commit that referenced this pull request Mar 13, 2019
Query based routing (continuation of #39)
@aviks
Copy link
Member

aviks commented Mar 13, 2019

continued in #81 . Thanks @sarvjeetsinghghotra for getting this started.

@aviks aviks closed this Mar 13, 2019
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.

6 participants