Captive Portal Application with Sockets

Hello Everyone
I have an existing application that serves http and web sockets using http.NewServeMux().

This works and remote devices can either access my server through shared Wifi or use the PC shared hotspot.

I would like to offer a wifi portal, like the wifi access point portals in cafes, with an automatic sign in page being offered (redirecting to the previous server) when first connecting; I believe that a captive portal might be able to do this.

I have tried using “GitHub - hsanjuan/go-captive: The world's simplest captive portal”. I don’t really know what I am doing :frowning: and have created the code below that runs separately from the http server.

I would like to know if this is possible without reconfiguring the host PC, i.e. without changing iptables, etc.

The intended use is for digital interactions where users can the connect with their mobile phones to the wifi (PC hotspot), with a page automatically opened, that allows them to interact with a web application running on the PC.

Thank you - Andy

	proxy := &captive.Portal{
		LoginPath:           "/editor",
		PortalDomain:        "quando.local",
		AllowedBypassPortal: false,
		// WebPath:             "staticContentFolder",
		// LoginHandler: func(){return true},
	}
	go func() {
		http.HandleFunc("/editor", func(w http.ResponseWriter, r *http.Request) {
			w.WriteHeader(http.StatusAccepted)
		})
	}()
	go func() {
		err := proxy.Run()
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	}()

The little I have learnt/understood indicates that I would have to capture all requests, e.g. using iptables, to get this working. So - for now, I will try other approaches…