kong插件之httplog
来源:互联网 发布:mac high sierra降级 编辑:程序博客网 时间:2024/06/03 17:19
转载:https://blog.lqsos.com/archives/33.html
创建API
curl -i -X POST \ --url http://localhost:8001/apis/ \ --data 'name=example-api' \ --data 'uris=/user' \ --data 'upstream_url=https://www.baidu.com'
返回值
{ "created_at":1513844533000, "strip_uri":true, "id":"16f447f2-846d-473f-929a-90aaab945142", "name":"example-api", "http_if_terminated":false, "preserve_host":false, "upstream_url":"https://www.baidu.com", "uris":[ "/user" ], "upstream_connect_timeout":60000, "upstream_send_timeout":60000, "upstream_read_timeout":60000, "retries":5, "https_only":false}
参数说明
consumer_id: 可选参数,消费者id(启用了消费者认证可以使用,根据id识别发出请求的消费者);config.http_endpoint: 日志接收服务器(包括使用的协议,http or https);config.method: 可选参数,默认POST,访问日志服务器的请求方式(可选值:PUT,PATCH,POST);config.timeout: 可选参数,默认10000毫秒,请求超时时间config.keepalive: 可选参数,默认60000毫秒,连接在关闭之前可存活时间
测试
curl -X POST http://localhost:8001/apis/example-api/plugins \ --data "name=http-log" \ --data "config.http_endpoint=http://test.my" \ --data "config.method=POST" \ --data "config.timeout=1000" \ --data "config.keepalive=1000"
返回值
{ "created_at":1513844551000, "config":{ "http_endpoint":"http://test.my", "timeout":1000, "method":"POST", "keepalive":1000, "content_type":"application/json" }, "id":"4fe57a5b-68d3-4f88-9824-d6071f2a68dd", "name":"http-log", "api_id":"16f447f2-846d-473f-929a-90aaab945142", "enabled":true}
test.my代码
<?php$myfile = fopen("testfile.txt", "w");$txt = file_get_contents("php://input");fwrite($myfile, $txt);fclose($myfile);
testfile.txt文件内容(格式化后的)
{ "api":{ "created_at":1513844533000, "strip_uri":true, "id":"16f447f2-846d-473f-929a-90aaab945142", "name":"example-api", "http_if_terminated":false, "https_only":false, "upstream_url":"https://www.baidu.com", "uris":[ "/user" ], "preserve_host":false, "upstream_connect_timeout":60000, "upstream_read_timeout":60000, "upstream_send_timeout":60000, "retries":5 }, "request":{ "querystring":{ }, "size":"82", "uri":"/user", "request_uri":"https://localhost:8443/user", "method":"GET", "headers":{ "host":"localhost:8443", "accept":"*/*", "user-agent":"curl/7.52.1" } }, "client_ip":"127.0.0.1", "latencies":{ "request":9, "kong":3, "proxy":6 }, "response":{ "headers":{ "content-type":"text/html; charset=UTF-8", "date":"Thu, 21 Dec 2017 08:41:21 GMT", "connection":"close", "via":"kong/0.11.0", "x-kong-proxy-latency":"3", "x-kong-upstream-latency":"6", "cache-control":"private, no-cache, no-store, proxy-revalidate, no-transform", "content-length":"2443", "pragma":"no-cache", "last-modified":"Mon, 23 Jan 2017 13:24:18 GMT", "set-cookie":"BDORZ=27315; max-age=86400; domain=.baidu.com; path=/", "server":"bfe/1.0.8.18", "accept-ranges":"bytes", "etag":""58860402-98b"" }, "status":200, "size":"2929" }, "tries":[ { "balancer_latency":0, "port":443, "ip":"14.215.177.38" } ], "started_at":1513845681183}
官方文档
阅读全文
0 0
- kong插件之httplog
- kong插件之Rate Limiting
- kong插件之Request Transformer
- 【kong系列四】之插件篇
- 【kong系列七】之ACL策略插件
- kong api gateway 插件之acl
- 【kong系列五】之 基本认证Basic Authentication插件
- 【kong系列六】之关键字认证key_auth插件
- 【kong系列八】之HMAC认证hmac-auth插件
- 【kong系列九】之限流rate-limiting插件
- Kong插件定制示例
- 【kong系列二】之 kong安装
- 【kong系列三】之 kong简单使用
- kong API gateway(四):插件
- 【kong系列十】之IP黑白名单ip-restriction限制插件
- 【kong系列十一】之JWT插件RSA256非对称加密使用
- kong
- 【kong系列一】之 API网关 & kong 概述
- 【转】简单工厂模式和策略模式的区别
- 作为技术应当懂得投资自己
- 【转】Java23种设计模式学习笔记【目录总贴】
- centos7 mysql数据库安装和配置
- java 设计模式之单例设计模式
- kong插件之httplog
- ubuntu中如何使用系统串口
- java设计模式之工厂设计模式(简单工厂设计模式、工厂设计模式、抽象设计模式)
- (转载)Android组件、工具、框架大全
- Jzoj3020 最多的约数
- base64编码解码js
- PIL image模块处理图片,struct从mnist文件集读取十张图片并分别显示标签和图片
- 一个优美炫酷的点赞动画
- “惊群”,看看nginx是怎么解决它的