Skip to content

My own custom web server implementation in Go, built entirely without relying on the standard net/http library.

License

Notifications You must be signed in to change notification settings

cilginc/webserver-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Environment Variables

The server can be configured using the following environment variables:

  • PORT
    The port on which the server listens for incoming HTTP requests.
    Default: :8080
    Example:
    PORT=":3000"
  • STATIC_DIR The absolute path to the directory from which static files are served. Default: Current working directory (.) Example:

    STATIC_DIR="/app/web"
  • WORKER_COUNT The number of worker goroutines to handle requests. Default: Number of available CPU cores Example:

    WORKER_COUNT=16

Running Locally

  1. Clone the repository:

    git clone https://github.com/cilginc/webserver-go.git
    cd webserver-go
  2. Build the server:

    go build -o bin ./cmd/server
    cd bin
  3. Start the server:

    # Using default configuration
    ./server
    
    # With custom port and static directory
    PORT=":3000" STATIC_DIR="./web/www" ./server

Running with Docker Compose

Add the following service definition to your docker-compose.yml file:

services:
  webserver:
    image: ghcr.io/cilginc/server:latest
    container_name: webserver
    ports:
      - "3000:3000"
    volumes:
      - ./www:/www
    environment:
      - PORT=:3000
      - STATIC_DIR=/www

Then start the container:

docker compose up -d

About

My own custom web server implementation in Go, built entirely without relying on the standard net/http library.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages