-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirst.rkt
31 lines (28 loc) · 863 Bytes
/
first.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#lang racket/base
(provide start)
(require web-server/http/request-structs
(only-in net/url
url->string)
(only-in (file "respond.rkt")
respond))
(define (start req)
(define method (request-method req))
(define body (request-post-data/raw req))
(define url/string (url->string (request-uri req)))
(define body-length
(cond [(bytes? body)
(bytes-length body)]
[else
0]))
(define message
(cond [(zero? body-length)
(format "~a ~a"
(string-upcase (bytes->string/utf-8 method))
url/string)]
[else
(format "~a ~a byte(s) to ~a"
(string-upcase (bytes->string/utf-8 method))
body-length
url/string)]))
(displayln message)
(respond))