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

nodejs搭建服务器基本思路 #2

Open
codevvvv9 opened this issue Dec 19, 2018 · 0 comments
Open

nodejs搭建服务器基本思路 #2

codevvvv9 opened this issue Dec 19, 2018 · 0 comments
Labels
basic nodejs The basis of nodejs

Comments

@codevvvv9
Copy link
Owner

codevvvv9 commented Dec 19, 2018

nodejs搭建服务器雏形的核心模块querystringurl

  • url模块更强大,包括了解析字符串的方法,并且有更强大的方法url.parse(request.url, true)
  • 解析后的url内容很丰富,见图
    url内容

通过urlpathname进一步判断路由

通过method进行不同的请求

  • request.method获得方法名
    • GET的话,requestUrl.query.请求参数判断请求的参数
    • POST的话,通过request.on(data, (data) => { //处理data} )
@codevvvv9 codevvvv9 pinned this issue Dec 19, 2018
@codevvvv9 codevvvv9 unpinned this issue Dec 19, 2018
@codevvvv9 codevvvv9 added the basic nodejs The basis of nodejs label Dec 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
basic nodejs The basis of nodejs
Projects
None yet
Development

No branches or pull requests

1 participant