Code Monkey home page Code Monkey logo

nginx-http-monitor's Introduction

nginx-http-monitor

  • OpenResty
  • Lua

开发过程中后端与客户端之前接口请求沟通成本过高,双方需要多次确认信息且很可能得到错误的信息, 基于该痛点开发了nginx-http-monitor

例如客户端请求如下:

> http :8080/abc\?x\=2\&y\=z a=b c=d

HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: text/html
Date: Fri, 27 Jul 2018 10:37:54 GMT
Server: openresty/1.13.6.1
Transfer-Encoding: chunked
X-Request-Id: e37c31bfb2d7f2c8af42fce8399d72f1

POST /abc x=2&y=z

会在返回头中生成X-Request-Id做为唯一ID,同时nginx日志会记录该HTTP请求的请求体和响应,日志中JSON中包含请求和响应信息

{
    "request_id": "e37c31bfb2d7f2c8af42fce8399d72f1",
    "uri": "/abc",
    "method": "POST",
    "response": {
        "time": 1532687874.289,
        "body": "POST /abc x=2&y=z\n",
        "headers": {
            "connection": "close",
            "content-type": "text/html",
            "x-request-id": "e37c31bfb2d7f2c8af42fce8399d72f1",
            "transfer-encoding": "chunked"
        },
        "status": 200,
        "duration": "0.001"
    },
    "request": {
        "host": "localhost",
        "body": "{\"a\": \"b\", \"c\": \"d\"}",
        "uri": "/abc",
        "post_args": {
            "{\"a\": \"b\", \"c\": \"d\"}": true
        },
        "method": "POST",
        "headers": {
            "host": "localhost:8080",
            "content-length": "20",
            "accept-encoding": "gzip, deflate",
            "user-agent": "HTTPie/0.9.3",
            "accept": "application/json",
            "content-type": "application/json",
            "connection": "keep-alive"
        },
        "get_args": {
            "y": "z",
            "x": "2"
        },
        "time": 1532687874.288
    },
    "host": "localhost"
}

安装

// FIXME TODO

参考:

nginx-http-monitor's People

Contributors

zhangbohan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.