// Handler function is handling HTTP requests and responding a
// different message depending on the extension (js, json or other)
Handler function is handling HTTP requests and responding a
different message depending on the extension (js, json or other)
// Handler function is handling HTTP requests and responding a // different message depending on the extension ( js json or other )
func (s *Server) handler(w http.ResponseWriter, r *http.Request) {
	var res string
	url := r.RequestURI
	ext := filepath.Ext(url)
	switch ext {
	case ".js":
		res = s.jsPage
	case ".json":
		res = s.jsonPage
	default:
		res = s.defaultPage
	}
	resBytes := []byte(res)
	w.Write(resBytes)
}
func ( s * Server ) handler ( w http . ResponseWriter , r * http . Request ) { var res string url := r . RequestURI ext := filepath . Ext ( url ) switch ext { case " " : res = s . jsPage case " " : res = s . jsonPage default : res = s . defaultPage } resBytes := [ ] byte ( res ) w . Write ( resBytes ) }
Handler function is handling HTTP requests and responding a
different message depending on the extension (js, json or other)
Handler function is handling HTTP requests and responding a different message depending on the extension ( js json or other )