const express = require('express');
const res = require('express/lib/response');
const app=express();
// 1.通过请求的方法类型get/put/post/delete
app.get('/demo',(req,res)=>{
// req:请求对象
// res:服务器响应对象
res.json({
message:'hello express rute from get demo'
})
})
app.post('/demo',(req,res)=>{
// req:请求对象
// res:服务器响应对象
res.json({
message:'hello express rute from post demo'
})
})
app.get('/user/byname',(req,res)=>{
let {name} = req.query;
res.json({
name
})
})
app.get('/user/byid',(req,res)=>{
let {id} = req.query;
res.json({
id
})
})
app.all('/all/demo',(req,res)=>{
res.json({
message: 'all demo',
method: req.method
})
})
app.listen(3000,()=>{
console.log('服务启动成功')
})
all的无论uri为什么都支持请求的写法,应用场景,比如日志

express的all方法支持所有请求方式请求

##需要定义一个 api/路由 需要满足 客户端 无论使用什么请求方式(get/post/detele/put)都可以得到响应
app.all('/demo',(req,res)=>{})
##无论客户端使用 任何的uri 我们的服务器都可以响应-->日志
express路由API使用
1.匹配所有的请求类型
app.all('path',func)
app.use('path',func)
2.匹配所有的uri
使用*来匹配所有的uri,常用的场景有打印请求日志 等等。
app.all('*',func)
app.use('*',func)
* app.use 通常用于中间件
## express
### all API的用法
#### 匹配所有的请求类型
```js
app.all('/demo',(req, res)=>{})
```
#### 匹配所有的uri
使用*来匹配所有的uri,常用的场景有打印请求日志 等等。
```js
app.all('*',(req, res)=>{})
```
express路由(.all)