mirror of
https://github.com/gen2brain/cam2ip.git
synced 2025-12-15 20:08:30 +00:00
Add index
This commit is contained in:
32
handlers/index.go
Normal file
32
handlers/index.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Index handler.
|
||||
type Index struct {
|
||||
}
|
||||
|
||||
// NewIndex returns new Index handler.
|
||||
func NewIndex() *Index {
|
||||
return &Index{}
|
||||
}
|
||||
|
||||
// ServeHTTP handles requests on incoming connections.
|
||||
func (i *Index) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "GET" && r.Method != "HEAD" {
|
||||
http.Error(w, "405 Method Not Allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
w.Write([]byte(`<html>
|
||||
<head><title>cam2ip</title></head>
|
||||
<body>
|
||||
<h1>cam2ip</h1>
|
||||
<p><a href='/html'>html</a></p>
|
||||
<p><a href='/jpeg'>jpeg</a></p>
|
||||
<p><a href='/mjpeg'>mjpeg</a></p>
|
||||
</body>
|
||||
</html>`))
|
||||
}
|
||||
@@ -58,9 +58,7 @@ func (s *Server) ListenAndServe() error {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
})
|
||||
http.Handle("/", newAuthHandler(handlers.NewIndex(), basic))
|
||||
|
||||
srv := &http.Server{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user