summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2026-05-21 20:51:23 +0200
committerxengineering <me@xengineering.eu>2026-05-21 20:51:23 +0200
commit242fa643db458663479a2fe3f1c757b5bf05cb5d (patch)
treeb9190fd97f7e5aaf8073d214b270700122b135ae
parent4e86ec4c9636eda91155592711c8459ae52ca5cc (diff)
downloadfinserv-242fa643db458663479a2fe3f1c757b5bf05cb5d.tar
finserv-242fa643db458663479a2fe3f1c757b5bf05cb5d.tar.zst
finserv-242fa643db458663479a2fe3f1c757b5bf05cb5d.zip
Add HTTP-based hello world
This demonstrates the HTTP server is working.
-rw-r--r--main.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/main.go b/main.go
index f5391cf..a595ab1 100644
--- a/main.go
+++ b/main.go
@@ -1,7 +1,18 @@
package main
import (
+ "fmt"
"log"
+ "net/http"
+ "time"
+
+ "github.com/gorilla/mux"
+)
+
+const (
+ Addr = "127.0.0.1:8000"
+ ReadTimeout = 15 * time.Second
+ WriteTimeout = 15 * time.Second
)
func main() {
@@ -11,4 +22,21 @@ func main() {
func run() {
log.Println("finserv finance server was started.")
defer log.Println("finserv finance server was stopped.")
+
+ r := mux.NewRouter()
+
+ r.HandleFunc("/", hello)
+
+ srv := &http.Server{
+ Handler: r,
+ Addr: Addr,
+ WriteTimeout: WriteTimeout,
+ ReadTimeout: ReadTimeout,
+ }
+
+ log.Fatal(srv.ListenAndServe())
+}
+
+func hello(w http.ResponseWriter, r *http.Request) {
+ fmt.Fprintln(w, "Hello world!")
}