一个简单的koa服务器示例,用于记录HTTP请求Header和body

一个简单的koa服务器示例,用于记录HTTP请求Header和body。 它也可以作为修改的基础,以满足您的需求。

Node.js HTTP工具

访问GitHub主页

共26Star

详细介绍

A simple koa server demo of logging HTTP request Headers and body. It could also be used as a basis for modifications to suit your needs.

$ npm install
$ npm start

Open another terminal window to send a HTTP request.

$ curl -d 'hello=world' -X POST http://127.0.0.1:3000

Server output.

> node server.js

listening Port 3000...

  <-- POST /


## Header

{
  "method": "POST",
  "url": "/",
  "header": {
    "host": "127.0.0.1:3000",
    "user-agent": "curl/7.65.3",
    "accept": "*/*",
    "content-length": "11",
    "content-type": "application/x-www-form-urlencoded"
  }
}

## Body

{"hello":"world"}
  --> POST / 200 18ms 0b
推荐源码