https://github.com/ashiqyousuf/http-go-server
Http server in golang from scratch
https://github.com/ashiqyousuf/http-go-server
concurrency golang sockets tcp-server trie-structure
Last synced: 18 days ago
JSON representation
Http server in golang from scratch
- Host: GitHub
- URL: https://github.com/ashiqyousuf/http-go-server
- Owner: ashiqYousuf
- Created: 2025-02-08T11:01:09.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-09T14:37:16.000Z (over 1 year ago)
- Last Synced: 2025-10-27T20:37:06.657Z (9 months ago)
- Topics: concurrency, golang, sockets, tcp-server, trie-structure
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HTTP Server in Golang from Scratch
## Introduction
This project is a simple HTTP server implemented in Go, built from scratch for learning purposes. It helps you understand how HTTP requests and responses work at a fundamental level without using any frameworks.
---
## Features
- Handles concurrent HTTP requests
- Demonstrates request parsing
- Responds proper HTTP response including Headers and Status Codes
- Lightweight and easy to modify
---
## HTTP Request & Response Format
HTTP communication follows a structured format:
```
--> e.g., "GET /path HTTP/1.1" \r\n
--> e.g., "Host: 127.0.0.1" (headers are separated by \r\n)
(blank line) --> "\r\n" (End of headers)
--> (Present in POST, PUT, etc.)
```
### Example HTTP Request (from client to server)
```
GET / HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: curl/7.68.0
Accept: */*
```
### Example HTTP Response (from server to client)
```
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 12
Hello World!
```
---
## Running the Server
1. Install Go if not already installed: [Download Go](https://go.dev/dl/)
2. Clone this repository:
```sh
git clone https://github.com/your-username/http-go-server.git
cd http-go-server
```
3. Run the server:
```sh
go run main.go
```
4. Open another terminal and send a request:
```sh
curl -v http://127.0.0.1:8080
```
---
## Contributing
Feel free to contribute by submitting a pull request or opening an issue. This project serves a great learning purpose.