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

Route by HTTP Method #105

Open
kumavis opened this issue Mar 20, 2015 · 15 comments
Open

Route by HTTP Method #105

kumavis opened this issue Mar 20, 2015 · 15 comments

Comments

@kumavis
Copy link

kumavis commented Mar 20, 2015

Is it possible to route based on HTTP Method, e.g. GET/POST ?

@Rush
Copy link
Member

Rush commented Mar 21, 2015

Not yet, no. That's a good idea though and a good candidate for extension for the router module. Are you using http-master from code or standalone?

@kumavis
Copy link
Author

kumavis commented Mar 21, 2015

I'm using it from code:
init
routing

@Rush
Copy link
Member

Rush commented Mar 22, 2015

What syntax do you propose for this functionality?

@kumavis
Copy link
Author

kumavis commented Mar 22, 2015

{
":inbox_tray:domain/* ": "3000/get/[1]",
":postbox:domain/* ": "2000/post/[1]"
}

@kumavis
Copy link
Author

kumavis commented Mar 22, 2015

json supports emoji, right? 👻

@Rush
Copy link
Member

Rush commented Mar 22, 2015

🐰

@kumavis
Copy link
Author

kumavis commented Mar 22, 2015

So i don't have much experience with this project -- what characters are not parsed currently?

this seems straightforward enough, but might conflict a bit

{
"GET:domain/* ": "3000/get/[1]",
"POST:domain/* ": "2000/post/[1]"
}

we could do whatever is easiest really

{
"GET=domain/* ": "3000/get/[1]",
"POST=domain/* ": "2000/post/[1]"
}

and i mean easiest not just out of laziness but also keeping the code simple and maintainable

@Rush
Copy link
Member

Rush commented Mar 22, 2015

how about this?

ports: {
  80: {
    router: {
      'domain/*': {
        GET: '3000/get/[1]',
        POST: '2000/post/[1]'
      }
    }
  }
}

@Nowaker
Copy link
Member

Nowaker commented Mar 22, 2015

@Rush CAPS is waste of keystrokes, btw, get or post would be sufficient and equally semantic. :)

@Rush
Copy link
Member

Rush commented Mar 22, 2015

Caps are needed to differentiate domains from http actions. Domains would be low caps.

@kumavis
Copy link
Author

kumavis commented Mar 22, 2015

i like that expansion. would you need to differentiate if you were using an object like that?

ports: {
  "80": {
    "router": {
      "domain/*": {
        "domain": "3000/get/[1]",
        "ACTION": "2000/post/[1]"
      }
    }
  }
}

@Rush
Copy link
Member

Rush commented Mar 22, 2015

In your example "domain" is already matched so it would be:

ports: {
  "80": {
    "router": {
      "domain/*": {
        "ACTION": "2000/post/[1]",
        "*": "3000/get/[1]"
      }
    }
  }
}

@Nowaker
Copy link
Member

Nowaker commented Mar 22, 2015

@Rush But domain is already defined in "domain/*", so having another domain one level deeper doesn't make sense, no?

@Rush
Copy link
Member

Rush commented Mar 22, 2015

If the "domain" matches couple of times no harm is done but as I've posted, it wouldn't be necessary.

@kumavis
Copy link
Author

kumavis commented Mar 22, 2015

👍 😸

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

No branches or pull requests

3 participants