Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer encapsulates HTTP server API.
func NewHTTPServer ¶
func NewHTTPServer(addr string, maxMessages int, logger *log.Logger) *HTTPServer
NewHTTPServer creates new HTTP server.
func (*HTTPServer) AddMessage ¶
func (h *HTTPServer) AddMessage(message *Message)
AddMessage prepends message to the slice.
func (*HTTPServer) HandleLog ¶
func (h *HTTPServer) HandleLog(w http.ResponseWriter, r *http.Request)
HandleLog replies with messages taken from UDP.
type Message ¶
type Message struct { IP string `json:"ip"` Payload string `json:"payload"` Time time.Time `json:"time"` }
Message is a struct that is created from UDP and served through HTTP.
func (*Message) MarshalJSON ¶
MarshalJSON implements Marshaler interface to reformat time to human readable format.
type UDPServer ¶
type UDPServer struct {
// contains filtered or unexported fields
}
UDPServer encapsulates UDP server API.
func NewUDPServer ¶
NewUDPServer creates new UDP server.
func (*UDPServer) ReadMessage ¶
ReadMessage reads bytes from UDP and serializes them into Message struct.
Click to show internal directories.
Click to hide internal directories.