simple (mock) web server framework written in awk
Webawk is a simple JSON API server framework for awk. This helps to make dummy-response server by only awk one-line command.
$ ./webawk.sh 'GET("/names") { b["names"][1]="Taro"; res(200, b) }'
$ curl localhost:8080/names
{"names":["Taro"]}
- GNU awk (5.x.x+)
- should be installed as
gawk
- should be installed as
- jq
- because I have not written a JSON parser yet 😏
Or you can run webawk docker image.
$ docker run -it -p 8080:8080 ghcr.io/syuparn/webawk:0.4.2 'GET("/names") { b["names"][1]="Taro"; res(200, b) }'
See https://github.com/users/Syuparn/packages/container/package/webawk for detail.
See ./examples
for practical examples.
You can also check command options by ./webawk.sh -h
.
-f progfile : run program file instead of program string
-h : get help
-n : how many requests it can handle (default: 2147483647)
-p port : port to listen (default: 8080)
-c command : which awk command to run (default: gawk)
Example:
webawk.sh 'GET("/names") {b["names"][1]="Taro"; res(200, b)}'
# test
$ ./test.sh