Skip to content

kristopher1027/http-haven

Repository files navigation

HTTP Haven

HTTP Haven is a hands-on Go project designed to help you learn and practice building HTTP servers, routing, handlers, and REST-style endpoints using Go’s standard net/http library.

The project is structured as a series of progressively challenging exercises, each implemented in its own Go file.


📁 Project Structure

http-haven/
├── cheatsheet.md # Quick reference for HTTP concepts & Go net/http
├── exercise.md # Instructions and goals for exercises
├── exercise1.go # Basic HTTP server
├── exercise2.go # Routing basics
├── exercise3.go # Query parameters
├── exercise4.go # JSON responses
├── exercise5.go # Request parsing
├── exercise6.go # Middleware concepts
├── exercise7.go # Advanced endpoint handling
├── main.go # Entry point / runner (if applicable)
├── go.mod # Go module definition
└── test_endpoints.sh # Script to test endpoints

🧩 Exercises Overview

Exercise 1 – Basic Server

Create a simple HTTP server that responds to /.

Exercise 2 – Routing

Add multiple routes with different handlers.

Exercise 3 – Query Params

Parse URL query parameters and respond dynamically.

Exercise 4 – JSON Responses

Return structured JSON from endpoints.

Exercise 5 – Request Body Parsing

Handle POST requests and decode JSON bodies.

Exercise 6 – Middleware

Implement logging or request timing wrappers.

Exercise 7 – Advanced Routing

Combine everything into a more realistic API design.

🧩 Exercise Breakdown

Exercise 1 – Basic HTTP Server

Build a simple server that responds to / with a message like "Hello, HTTP Haven!".

Exercise 2 – Routing

Create multiple endpoints such as:

/ /hello /status

Each should return a different response.

Exercise 3 – Query Parameters

Handle URLs like:

/greet?name=John

Return a personalized response using the query parameter.

Exercise 4 – JSON Responses

Return structured JSON:

{
  "message": "Hello",
  "status": "success"
}

Exercise 5 – Request Body Parsing

Handle POST requests with JSON input like:

{
  "name": "John",
  "age": 25
}

Parse and respond with processed data.

Exercise 6 – Middleware

Implement middleware patterns such as:

Logging requests Measuring response time Basic request validation

Exercise 7 – Advanced Routing

Combine everything into a mini API with:

Multiple endpoints JSON input/output Middleware wrapping Clean handler structure

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors