Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

daytonaio-experiments/sample-go-web-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample Go/Web Server

A simple Go web server demonstrating basic HTTP routing, middleware, and graceful shutdown using Gorilla Mux and Logrus.


🚀 Getting Started

Open Using Daytona

  1. Install Daytona: Follow the Daytona installation guide.
  2. Create the Workspace:
    daytona create https://github.com/daytonaio/sample-go-web-server.git
  3. Install Dependencies:
    go mod tidy
  4. Start the Application:
    go run main.go

✨ Features

  • Simple HTTP server with two routes
  • Structured logging with Logrus
  • Middleware for request logging
  • Panic recovery middleware
  • Graceful server shutdown
  • Environment variable-based port configuration

🛠️ Project Structure

  • main.go: Primary application file with server logic
  • go.mod: Go module dependency management

🔧 Dependencies


Using Postman/Insomnia

  1. Plain Text Endpoint:
    • Set method to GET
    • Enter URL: http://localhost:8080/
    • Expected Response:
  Hello, World!
  1. JSON Endpoint:
    • Set method to GET
    • Enter URL: http://localhost:8080/json
    • Expected Response:
  {
    "message": "Hello, JSON World!"
  }

📡 Endpoints

  • GET /: Returns a plain text "Hello, World!" message
  • GET /json: Returns a JSON response

🌐 Configuration

Configure the server port using the PORT environment variable. Defaults to 8080 if not specified.

About

Sample Go Web Server Application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages