MCPcopy Index your code
hub / github.com/assafmo/SQLiteQueryServer / buildHelpMessage

Function buildHelpMessage

main.go:218–290  ·  view source on GitHub ↗
(helpMessage string, queryString string, queryStmt *sql.Stmt, serverPort uint)

Source from the content-addressed store, hash-verified

216}
217
218func buildHelpMessage(helpMessage string, queryString string, queryStmt *sql.Stmt, serverPort uint) string {
219 helpMessage += fmt.Sprintf(`Query:
220 %s
221
222`, queryString)
223
224 queryParamsCount, err := countParams(queryStmt)
225 if err != nil {
226 log.Printf("Error extracting params count from query: %v\n", err)
227 } else {
228 helpMessage += fmt.Sprintf(`Params count (question marks in query):
229 %d
230
231`, queryParamsCount)
232 }
233
234 helpMessage += fmt.Sprintf(`Request examples:
235 $ echo -e "$QUERY1_PARAM1,$QUERY1_PARAM2\n$QUERY2_PARAM1,$QUERY2_PARAM2" curl "http://$ADDRESS:%d/query" --data-binary @-
236 $ curl "http://$ADDRESS:%d/query" -d "$PARAM_1,$PARAM_2,...,$PARAM_N"
237
238 - Request must be a HTTP POST to "http://$ADDRESS:%d/query".
239 - Request body must be a valid CSV.
240 - Request body must not have a CSV header.
241 - Each request body line is a different query.
242 - Each param in a line corresponds to a query param (a question mark in the query string).
243 - Static query (without any query params):
244 - The request must be a HTTP GET to "http://$ADDRESS:%d/query".
245 - The query executes only once.
246
247`, serverPort, serverPort, serverPort, serverPort)
248
249 helpMessage += fmt.Sprintf(`Response example:
250 $ echo -e "github.com\none.one.one.one\ngoogle-public-dns-a.google.com" | curl "http://$ADDRESS:%d/query" --data-binary @-
251 [
252 {
253 "in": ["github.com"],
254 "headers": ["ip","dns"],
255 "out": [
256 ["192.30.253.112","github.com"],
257 ["192.30.253.113","github.com"]
258 ]
259 },
260 {
261 "in": ["one.one.one.one"],
262 "headers": ["ip","dns"],
263 "out": [
264 ["1.1.1.1","one.one.one.one"]
265 ]
266 },
267 {
268 "in": ["google-public-dns-a.google.com"],
269 "headers": ["ip","dns"],
270 "out": [
271 ["8.8.8.8","google-public-dns-a.google.com"]
272 ]
273 }
274 ]
275

Callers 1

initQueryHandlerFunction · 0.85

Calls 1

countParamsFunction · 0.85

Tested by

no test coverage detected