Replace use of first-only with match

This commit is contained in:
Tony Garnock-Jones 2012-02-17 16:09:23 -05:00
parent 1c3ebd17bd
commit 87943e435b
1 changed files with 4 additions and 8 deletions

View File

@ -64,11 +64,6 @@
(spawn udp-driver)
(spawn (nested-vm boot-server)))))
(define (first-only xs)
(if (null? xs)
xs
(list (car xs))))
(define (handle-request soa-rr zone request)
(match-define (dns-request request-message request-source request-sink) request)
@ -133,9 +128,10 @@
;; TODO: check opcode and direction in request
;; TODO: think again about multiple questions in one packet
(map (lambda (q)
(dns-reply (answer-question q make-reply) request-sink request-source))
(first-only (dns-message-questions request-message))))
(match (dns-message-questions request-message)
['() '()]
[(cons q _)
(list (dns-reply (answer-question q make-reply) request-sink request-source))]))
(require "test-rrs.rkt")
(start-server (test-port-number) test-soa-rr test-rrs)