Skip to content

Commit

Permalink
Add example server
Browse files Browse the repository at this point in the history
  • Loading branch information
muzzammilshahid committed Jul 12, 2024
1 parent fa073fc commit 3703848
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"flag"
"log"

"github.com/xconnio/xconn-go"
)

func main() {
host := flag.String("host", "127.0.0.1", "host to listen on")
port := flag.Int("port", 8080, "port to listen on")
realm := flag.String("realm", "realm1", "realm to use")
help := flag.Bool("help", false, "print help")

flag.Parse()

if *help {
flag.Usage()
return
}

r := xconn.NewRouter()
r.AddRealm(*realm)

server := xconn.NewServer(r, nil)
err := server.Start(*host, *port)
if err != nil {
log.Fatal("Failed to start server:", err)
}
}

0 comments on commit 3703848

Please sign in to comment.