Changeset 15256 in project
- Timestamp:
- 07/25/09 20:00:18 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wiki/eggref/4/xml-rpc
r15255 r15256 102 102 <procedure>(make-xml-rpc-request-handler procedures)</procedure> 103 103 104 This creates a procedure which accepts two arguments; an [ intarweb]104 This creates a procedure which accepts two arguments; an [[intarweb]] 105 105 request object and a response object. It will read an XML-RPC request 106 106 from the request-port and respond to the request with the response … … 411 411 -> Hello, you! 412 412 413 The same server, running as a Spiffy vhost request handler: 414 415 <enscript highlight=scheme> 416 (use spiffy xml-rpc) 417 418 (define (say-hello var) 419 (sprintf "Hello, ~A!" var) ) 420 421 (vhost-map 422 `(("test1" . ,(let ((handler (make-xml-rpc-request-handler 423 `((hello . ,say-hello))))) 424 (lambda _ 425 (handler (current-request) 426 (current-response))))))) 427 428 (start-server) 429 </enscript> 430 431 When requesting any resource under the host {{test1}}, this will 432 trigger the XML-RPC handler. 433 434 <enscript highlight=scheme> 435 (require-extension xml-rpc-client) 436 437 (define srv1 (xml-rpc-server "http://test1:8080/RPC2")) 438 (define hello1 (srv "hello")) 439 440 (define srv2 (xml-rpc-server "http://localhost:8080/RPC2")) 441 (define hello2 (srv "hello")) 442 443 444 ;; Prints: 445 ;; -> Hello, you! 446 (print "-> " (hello1 "you")) 447 448 ;; Throws an (exn http client-error), with 404 not found: 449 (print "-> " (hello2 "you")) 450 </enscript> 451 452 If you wish more control over exactly under which URIs the XML 453 resource is available, you could have a look at [[uri-dispatch]], or 454 roll your own URI path checker. 455 413 456 === Changelog 414 457
Note: See TracChangeset
for help on using the changeset viewer.