Mercurial Hosting > luan
view src/goodjava/webserver/examples/Params.java @ 1831:8f9ae295bf6a default tip
add Hosted.authorize
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 26 Sep 2024 15:07:45 -0600 |
parents | fa066aaa068c |
children |
line wrap: on
line source
package goodjava.webserver.examples; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.IOException; import java.util.Map; import goodjava.webserver.Handler; import goodjava.webserver.Request; import goodjava.webserver.Response; import goodjava.webserver.ResponseOutputStream; public final class Params implements Handler { public Response handle(Request request) { Response response = new Response(); response.headers.put( "Content-Type", "text/plain; charset=utf-8" ); try { Writer writer = new OutputStreamWriter( new ResponseOutputStream(response) ); for( Map.Entry<String,Object> entry : request.parameters.entrySet() ) { writer.write(entry.getKey()+" = "+entry.getValue()+"\n"); } writer.close(); } catch(IOException e) { throw new RuntimeException(e); } return response; } }