comparison src/goodjava/webserver/examples/Params.java @ 1402:27efb1fcbcb5

move luan.lib to goodjava
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 17 Sep 2019 01:35:01 -0400
parents src/luan/lib/webserver/examples/Params.java@643cf1c37723
children fa066aaa068c
comparison
equal deleted inserted replaced
1401:ef1620aa99cb 1402:27efb1fcbcb5
1 package goodjava.webserver.examples;
2
3 import java.io.Writer;
4 import java.io.OutputStreamWriter;
5 import java.io.IOException;
6 import java.util.Map;
7 import goodjava.webserver.Handler;
8 import goodjava.webserver.Request;
9 import goodjava.webserver.Response;
10 import goodjava.webserver.ResponseOutputStream;
11
12
13 public final class Params implements Handler {
14
15 public Response handle(Request request) {
16 Response response = new Response();
17 response.headers.put( "content-type", "text/plain; charset=utf-8" );
18 try {
19 Writer writer = new OutputStreamWriter( new ResponseOutputStream(response) );
20 for( Map.Entry<String,Object> entry : request.parameters.entrySet() ) {
21 writer.write(entry.getKey()+" = "+entry.getValue()+"\n");
22 }
23 writer.close();
24 } catch(IOException e) {
25 throw new RuntimeException(e);
26 }
27 return response;
28 }
29
30 }