1
1
# mysql_udf_http_golang
2
+ [ ![ MySQL UDF] ( https://img.shields.io/badge/MySQL-UDF-blue.svg )] ( https://dev.mysql.com/ ) [ ![ MariaDB UDF] ( https://img.shields.io/badge/MariaDB-UDF-blue.svg )] ( https://mariadb.com/ )
3
+
2
4
[ MySQL] ( https://dev.mysql.com/ ) or [ MariaDB] ( https://mariadb.com/ ) UDF(User-Defined Functions) HTTP Client Plugin
3
5
4
6
Call RESTful API on query.
@@ -27,7 +29,7 @@ Build output is `http.so`, move file to `plugin_dir` path.
27
29
if you don't know ` plugin_dir ` path.
28
30
Command input this on MySQL, MariaDB connection.
29
31
30
- ``` query
32
+ ``` sql
31
33
SHOW VARIABLES LIKE ' plugin_dir' ;
32
34
```
33
35
@@ -80,7 +82,7 @@ SELECT http_help();
80
82
81
83
- ** Prototype**
82
84
``` sql
83
- SELECT http_get(url, option ...);
85
+ SELECT http_get(url, options ...);
84
86
```
85
87
86
88
- ** Simple Request**
@@ -90,14 +92,12 @@ SELECT http_get('http://example.com');
90
92
** Return**
91
93
``` javascript
92
94
{
93
- " Body" : String (HTML (Default), Base64, Hexdecimal)
95
+ " Body" : String (HTML (Default), Base64, Hexdecimal)
94
96
}
95
97
```
96
98
97
99
- ** Output Option**
98
- ` -O outputType ` Define kind of result.
99
-
100
- - Kinds
100
+ ` -O {outputType} ` Define kind of result.
101
101
` PROTO ` , ` STATUS ` or ` STATUS_CODE ` , ` HEADER ` , ` BODY ` (default), ` FULL `
102
102
` -O PROTO|STATUS|HEADER|BODY ` same this ` -O FULL ` .
103
103
@@ -107,23 +107,71 @@ SELECT http_get('http://example.com', '-O FULL');
107
107
** Return**
108
108
``` javascript
109
109
{
110
- " Proto" : String (Http Version, HTTP / 1.0 , HTTP / 1.1 , HTTP / 2.0 ),
111
- " Status" : String (Status Code, 200 OK , 404 NOT FOUND ),
112
- " Header" : JSON (` {Key : Array, ...}` ),
113
- " Body" : String (HTML (Default), Base64, Hexdecimal)
110
+ " Proto" : String (Http Version, HTTP / 1.0 , HTTP / 1.1 , HTTP / 2.0 ),
111
+ " Status" : String (Status Code, 200 OK , 404 NOT FOUND ... ),
112
+ " Header" : JSON (` {Key : Array, ...}` ),
113
+ " Body" : String (HTML (Default), Base64, Hexdecimal)
114
114
}
115
115
```
116
- #
117
- #
118
- #
119
- #
120
- ### writing... plz wait...
121
- ### Add Soon
116
+ - ** Custom Header**
117
+ Option param input ` -H {key}:{value} ` .
118
+ ``` sql
119
+ SELECT http_get(' http://example.com' , ' -O FULL' , ' -H CustomKey:CustomValue' , ' -H Authorization:Bearer a1b2c3d4-123e-5678-9fgh-ijk098765432' )
120
+ ```
121
+ ** Like this**
122
+ ``` http
123
+ GET / HTTP/1.1
124
+ Host: example.com
125
+ CustomKey: CustomValue
126
+ Authorization: Bearer a1b2c3d4-123e-5678-9fgh-ijk098765432
127
+ User-Agent: Go-http-client/1.1
128
+ Accept-Encoding: gzip
129
+ ```
130
+
122
131
### - POST Method
132
+ - ** Prototype**
133
+ ``` sql
134
+ SELECT http_post(url, contentType, body, options...)
135
+ ```
136
+ - ** Simple Request(No Body)**
137
+ ``` sql
138
+ SELECT http_post(' http://example.com' , ' ' , ' ' );
139
+ ```
140
+ - ** Simple Request(Json Body)**
141
+ ``` sql
142
+ SELECT http_post(' http://example.com' , ' application/json' , ' {"Hello":"World"}' );
143
+ ```
144
+ ** Like this**
145
+ ``` http
146
+ POST / HTTP/1.1
147
+ Host: example.com
148
+ Content-Type: application/json
149
+ Content-Length: 17
150
+ User-Agent: Go-http-client/1.1
151
+ Accept-Encoding: gzip
152
+
153
+
154
+ {"Hello":"World"}
155
+ ```
156
+ ### - Raw Method
157
+ - ** Prototype**
123
158
``` sql
124
- SELECT http_post();
159
+ SELECT http_raw(method, url, body, options...)
125
160
```
126
-
161
+
162
+ - ** PUT**
163
+ ``` sql
164
+ SELECT http_raw(' PUT' , url, body, options...)
165
+ ```
166
+ - ** PATCH**
167
+ ``` sql
168
+ SELECT http_raw(' PATCH' , url, body, options...)
169
+ ```
170
+ - ** DELETE**
171
+ ``` sql
172
+ SELECT http_raw(' DELETE' , url, body, options...)
173
+ ```
174
+
127
175
License
128
176
---
129
- [ ` THE BEER-WARE LICENSE (Revision 42) ` ] ( http://en.wikipedia.org/wiki/Beerware )
177
+ [ ` THE BEER-WARE LICENSE (Revision 42) ` ] ( http://en.wikipedia.org/wiki/Beerware )
0 commit comments