https://github.com/thatbeautifuldream/go-http-server
Server Sent Events / Event Streaming using Go
https://github.com/thatbeautifuldream/go-http-server
event-streaming go server-sent-events sse
Last synced: 6 months ago
JSON representation
Server Sent Events / Event Streaming using Go
- Host: GitHub
- URL: https://github.com/thatbeautifuldream/go-http-server
- Owner: thatbeautifuldream
- Created: 2024-12-07T18:34:30.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-12-08T19:37:06.000Z (10 months ago)
- Last Synced: 2025-02-06T13:21:25.304Z (8 months ago)
- Topics: event-streaming, go, server-sent-events, sse
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Go HTTP Server
This is a simple HTTP server written in Go that responds with "hello, world" when accessed.
## Prerequisites
- Go installed on your machine. You can download it from [golang.org](https://golang.org/dl/).
## Setup
1. Clone the repository or create a new directory for the project:
```bash
mkdir go-http-server
cd go-http-server
```2. Initialize the Go module:
```bash
go mod init go-http-server
```3. Create a file named `main.go` and add the server code.
## Running the Server
1. Run the server using the following command:
```bash
go run main.go
```2. Open a web browser and go to `http://localhost:3000` to see the "hello, world" message.
## Code Overview
- The server listens on port 3000 by default.
- The `events` function handles requests to the `/events` URL and responds with an event stream.## Running with Docker
1. Build the Docker image:
```bash
docker build -t go-http-server .
```2. Run the Docker container:
```bash
# Start the service
docker-compose up -d
```3. View logs
```bash
docker-compose logs -f
```4. Check container status
```bash
docker-compose ps
```5. Restart
```bash
docker-compose restart```
6. Update and rebuild
```bash
docker-compose up -d --build
```