Skip to content

Commit 1afd557

Browse files
author
jgodbou
committed
Update hello-world-server to accept octet vector
1 parent 6931a3e commit 1afd557

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

hello-world-server.asd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
:description "CL-protobuf Hello World Server"
66
:long-description "CL-protobuf Hello World Server"
77
:defsystem-depends-on (:cl-protobufs)
8-
:depends-on (:hunchentoot :flexi-streams
9-
:cl-base64 :protobuf-utilities)
8+
:depends-on (:hunchentoot)
109
:components
1110
((:module "src"
1211
:serial t

hello-world-server.lisp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
(:export #:start-server
55
#:stop-server)
66
(:local-nicknames
7-
(#:hwp #:cl-protobufs.hello-world)
8-
(#:pu #:protobuf-utilities)))
7+
(#:hwp #:cl-protobufs.hello-world)))
98

109
(in-package :hello-world-server)
1110

@@ -17,14 +16,19 @@
1716

1817
(setf *acceptor* nil)
1918

20-
(define-easy-handler (hello-world :uri "/hello")
21-
((request :parameter-type 'string))
22-
(pu:with-deserialized-protos-serializing-return ((request . hwp:request))
23-
(hwp:make-response
24-
:response
25-
(if (hwp:request.has-name request)
26-
(format nil "Hello ~a" (hwp:request.name request))
27-
"Hello"))))
19+
(define-easy-handler (hello-world :uri "/hello") ()
20+
(setf (hunchentoot:content-type*) "application/octet-stream")
21+
(let* ((post-request (raw-post-data))
22+
(request (if post-request
23+
(cl-protobufs:deserialize-from-bytes
24+
'hwp:request post-request)
25+
(hwp:make-request)))
26+
(response (hwp:make-response
27+
:response
28+
(if (hwp:request.has-name request)
29+
(format nil "Hello ~a" (hwp:request.name request))
30+
"Hello"))))
31+
(cl-protobufs:serialize-to-bytes response)))
2832

2933
(defun stop-server ()
3034
(when *acceptor*

0 commit comments

Comments
 (0)