What is websocket url "ws://{{$}}/ws" means?
I work with websocket in go. And I got a websocket url format from a
trivial example that I google like this:
ws://{{$}}/ws
The sentence code(javascript client) is:
<html>
<head>
<title>Chat Example</title>
<script type="text/javascript">
$(function() {
......
if (window["WebSocket"]) {
conn = new WebSocket("ws://{{$}}/ws");
conn.onclose = function(evt) {
appendLog($("<div><b>Connection closed.</b></div>"))
}
conn.onmessage = function(evt) {
appendLog($("<div/>").text(evt.data))
}
} else {
appendLog($("<div><b>Your browser does not support
WebSockets.</b></div>"))
}
......
});
</script>
</head>
</html>
And go server's HandleFunc() like this:
func main() {
http.HandleFunc("/", serveHome)
http.HandleFunc("/ws", serveWs)
err := http.ListenAndServe(:8080, nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
I thought it would be a regular expression while actually I can't explain it.
I test it on my own PC browser, and connect success with:
http://localhost:8080
but
http://ip:8080 (which ip is my computer's also the litsening server's ip)
not. And why?
Of course it works when I change "ws://{{$}}/ws" to a certain url. But I
want to know why?And what can this expression matching for?