Package server

Class SendMessageHandler

java.lang.Object
server.SendMessageHandler
All Implemented Interfaces:
HttpHandler

public class SendMessageHandler extends Object implements HttpHandler
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    handle(HttpExchange httpexchange)
    Http handler for sending messages to a chat Example: curl --header "Content-type: application/json" \ --request POST \ --data '{"chat": "Hennings Privata chat", "message": {"text": "Hämligt meddelande :)", "user": {"name": "Coola Henning", "id": "1"}, "time": "2026-02-04T11:14:05Z"}}' \ http://localhost:2345/send_message

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SendMessageHandler

      public SendMessageHandler(DatabaseHandler databaseHandler)
  • Method Details

    • handle

      public void handle(HttpExchange httpexchange) throws IOException
      Http handler for sending messages to a chat Example: curl --header "Content-type: application/json" \ --request POST \ --data '{"chat": "Hennings Privata chat", "message": {"text": "Hämligt meddelande :)", "user": {"name": "Coola Henning", "id": "1"}, "time": "2026-02-04T11:14:05Z"}}' \ http://localhost:2345/send_message
      Specified by:
      handle in interface HttpHandler
      Throws:
      IOException