🔍

htreq.o

Library for query platform over HTTP.

To properly work, must be defined the system environment variable OHOME with a path to the platform.

To simply start the server need call .http.run[].

Elements are used to start the server

Name Description / comments
.http.default.bind Get default / set string with binding ip:port
.http.default.host Get default / set string with user name
.http.default.home Get default / set string with current dir
.http.default.handle[<sock>;<headers>] Request handler function (automatically set by htreq module)
.http.run[<creds>] Start http server

Examples

Start HTTP query server:

o)// Save this as query_server.o and run with:
o)// tachyon -c 0 -f query_server.o
o)
o)load[getenv[`OHOME];"htreq"];
o)// Server starts automatically and listens for HTTP requests
o)// Query format: GET /request.FORMAT?O_EXPRESSION

Query server from command line:

# Simple calculation (JSON format)
$ curl "http://localhost:8080/request.json?1+2+3"
6

# Create and query table (JSON format)
$ curl "http://localhost:8080/request.json?t:+\`a\`b!(1 2 3;4 5 6)"
{"a":[1,2,3],"b":[4,5,6]}

# Query table (CSV format)
$ curl "http://localhost:8080/request.csv?+\`name\`age!(\"Alice\" \"Bob\";25 30)"
name,age
Alice,25
Bob,30

# Execute expression
$ curl "http://localhost:8080/request.json?2 xexp 10"
1024

The htreq.o module executes arbitrary O code from HTTP requests. Only use on trusted networks or implement authentication. Never expose to public internet without proper security measures.

Auxiliary elements

Name Description / comments
.ht.jsn[<x>] Convert result to JSON format
.ht.csv[<x>] Convert result to CSV format
.ht.proc[<sock>;<fmt>;<req>] Process HTTP request and execute O expression
.ht.catch[<sock>;<req>;<msg>] Handle errors during request processing