Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env gosh | ||
|
||
;; | ||
;; Receives json via POST message and returns it in json, | ||
;; as well as writes it out to stdout. Useful to be a receiving | ||
;; end of testing json post feature. | ||
;; | ||
;; Run it in the top source directory of Gauche-makiki. | ||
;; | ||
|
||
(add-load-path ".." :relative) | ||
(use makiki) | ||
(use gauche.parseopt) | ||
|
||
(define (main args) | ||
(let-args (cdr args) ([port "p|port=i" 8012]) | ||
(start-http-server :access-log #t :error-log #t :port port)) | ||
0) | ||
|
||
(define (handler req app) | ||
(let1 body (request-param-ref req "json-body" :default '()) | ||
(display #"==== ~(sys-ctime (current-time))") | ||
(pprint body) | ||
(respond/ok req `(json ,body)))) | ||
|
||
(define-http-handler #/.*/ (with-post-json handler)) |