go-server

command module
v0.0.0-...-9113170 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 14 Imported by: 0

README

go-http-server

This project implements HTTP and HTTPS servers using Go's standard libraries (net and crypto/tls). It serves static files, handles basic HTTP GET requests, and logs request details. Configurable via command-line flags for port, directory, and optional HTTPS with custom SSL/TLS certificates. Ideal for educational purposes to explore fundamental server concepts.

To run the http server with default config

go run main.go config.go server.go --dir=./public --port=3000

To run the https server generate keys using openssl and include the paths in flag

go run main.go config.go server.go --dir=./public --port=3000 --https --cert=./tlsCert/cert.pem --key=./tlsCert/key.pem

server runs in

http://localhost:3000/home
https://localhost:3000/home
Command-Line Flags
Flag Description Default Value
--dir Directory to serve files from .
--port Port to bind the server to 4221
--https Enable HTTPS (requires cert and key) false
--cert Path to SSL certificate file cert.pem
--key Path to SSL key file key.pem

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL