forked from RackHD/inservice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp.go
More file actions
25 lines (21 loc) · 621 Bytes
/
http.go
File metadata and controls
25 lines (21 loc) · 621 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package main
import (
"fmt"
"net/http"
)
// HTTPServer serves the InService Agent configuration file as part of the SSDP
// advertisement process for consumers to identify the configuration of the Agent.
type HTTPServer struct {
Address string
Port int
ConfigFile string
URI string
}
// Serve runs the HTTPServer in blocking mode.
func (s *HTTPServer) Serve() {
http.HandleFunc(fmt.Sprintf("/%s", s.URI), s.handler)
http.ListenAndServe(fmt.Sprintf("%s:%d", s.Address, s.Port), nil)
}
func (s *HTTPServer) handler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, s.ConfigFile)
}