| | |
| | | /* |
| | | * To change this license header, choose License Headers in Project Properties. |
| | | * To change this template file, choose Tools | Templates |
| | | * and open the template in the editor. |
| | | Mediazentrale - Personal Media Center |
| | | Copyright (C) 2021 Ulrich Hilger |
| | | |
| | | This program is free software: you can redistribute it and/or modify |
| | | it under the terms of the GNU Affero General Public License as |
| | | published by the Free Software Foundation, either version 3 of the |
| | | License, or (at your option) any later version. |
| | | |
| | | This program is distributed in the hope that it will be useful, |
| | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| | | GNU Affero General Public License for more details. |
| | | |
| | | You should have received a copy of the GNU Affero General Public License |
| | | along with this program. If not, see <https://www.gnu.org/licenses/>. |
| | | */ |
| | | package de.uhilger.mediaz.api; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.sun.net.httpserver.HttpExchange; |
| | | import com.sun.net.httpserver.HttpHandler; |
| | | import java.io.BufferedReader; |
| | |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.io.OutputStream; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | |
| | | /** |
| | | * |
| | | * @author ulrich |
| | | * @author Ulrich Hilger |
| | | * @version 1, 8.4.2021 |
| | | */ |
| | | public abstract class AbstractHandler extends JsonHelper implements HttpHandler { |
| | | |
| | |
| | | } |
| | | break; |
| | | } |
| | | logger.fine(response); |
| | | e.sendResponseHeaders(code, response.length()); |
| | | OutputStream os = e.getResponseBody(); |
| | | os.write(response.getBytes()); |
| | |
| | | } |
| | | r.close(); |
| | | String json = sb.toString(); |
| | | logger.log(Level.FINE, "json: {0}", json); |
| | | return json; |
| | | } |
| | | |