Skip to content

Commit

Permalink
implement HEAD request
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Jul 4, 2018
1 parent f052cb5 commit 64827f1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/server.go
@@ -1,6 +1,7 @@
package croc

import (
"fmt"
"net"
"net/http"
"time"
Expand All @@ -19,6 +20,11 @@ func (c *Croc) startServer() (err error) {

var upgrader = websocket.Upgrader{} // use default options
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// check if HEAD request
if r.Method == "HEAD" {
fmt.Fprintf(w, "ok")
return
}
// incoming websocket request
log.Debugf("connecting remote addr: %+v", r.RemoteAddr)
ws, err := upgrader.Upgrade(w, r, nil)
Expand Down Expand Up @@ -65,6 +71,7 @@ func (c *Croc) startServer() (err error) {
}
})
log.Debugf("listening on port %s", c.ServerPort)
fmt.Printf("listening on port %s\n", c.ServerPort)
err = http.ListenAndServe(":"+c.ServerPort, nil)
return
}
Expand Down

0 comments on commit 64827f1

Please sign in to comment.