Skip to content
codewithdpkPublic

About

A lightweight HTTP server framework built from scratch in Go using raw TCP connections. No external dependencies, just pure Go standard library.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

narad

A lightweight HTTP server framework built from scratch in Go using raw TCP connections. No external dependencies, just pure Go standard library.

Features

  • 🚀 Built from scratch using TCP sockets
  • 🛣️ Fast HTTP routing with support for path parameters
  • 📦 Simple and intuitive API
  • 🔄 JSON response helper
  • ⚡ Concurrent request handling with goroutines
  • 🎯 Pattern matching for dynamic routes

Installation

go get github.com/codewithdpk/narad

Quick Start

Here's a simple example to get you started:

package main

import (
	"github.com/codewithdpk/narad/internal/server"
)

func main() {
	// Create a new router
	r := server.New()

	// Define a simple route
	r.Handle("GET", "/", func(ctx *server.Context) {
		ctx.JSON(200, []byte(`{"message": "Hello, World!"}`))
	})

	// Start the server on port 8080
	r.Serve(":8080")
}

Run the example:

go run examples/basic_server.go

Test it with curl:

curl http://localhost:8080/

Usage Examples

Basic Routes

r := server.New()

// GET request
r.Handle("GET", "/api/users", func(ctx *server.Context) {
	ctx.JSON(200, []byte(`{"users": []}`))
})