@@ -97,25 +97,22 @@ Once you have a Mojo project set up locally,
9797 For example, to make a ` Printer ` service that prints some details about the request to console:
9898
9999 ``` mojo
100- from lightbug_http import *
100+ from lightbug_http.http import HTTPRequest, HTTPResponse, OK
101+ from lightbug_http.strings import to_string
102+ from lightbug_http.header import HeaderKey
101103
102104 @value
103105 struct Printer(HTTPService):
104106 fn func(mut self, req: HTTPRequest) raises -> HTTPResponse:
105- var uri = req.uri
106- print("Request URI: ", to_string(uri.request_uri))
107-
108- var header = req.headers
109- print("Request protocol: ", req.protocol)
110- print("Request method: ", req.method)
111- print(
112- "Request Content-Type: ", to_string(header[HeaderKey.CONTENT_TYPE])
113- )
114-
115- var body = req.body_raw
116- print("Request Body: ", to_string(body))
117-
118- return OK(body)
107+ print("Request URI:", req.uri.request_uri)
108+ print("Request protocol:", req.protocol)
109+ print("Request method:", req.method)
110+ if HeaderKey.CONTENT_TYPE in req.headers:
111+ print("Request Content-Type:", req.headers[HeaderKey.CONTENT_TYPE])
112+ if req.body_raw:
113+ print("Request Body:", to_string(req.body_raw))
114+
115+ return OK(req.body_raw)
119116 ```
120117
1211186 . Start a server listening on a port with your service like so.
0 commit comments