func (e *TemplateDeliverer) ServeHTTP(writer http.ResponseWriter, request *http.Request) { if request.Method != "GET" { log.Printf("%s %s: wrong method for template handling", request.Method, request.URL) failer.ServeMethodNotAllowed(writer, request) return } readCloser, err := e.loader.LoadResource(request.URL.Path) if err != nil { log.Printf("%s %s: error while opening template resource: %s", request.Method, request.URL, err) failer.ServeNotFound(writer, request) return } defer readCloser.Close() writer.Header().Set("Content-Type", e.detectMimeType(request)) _, err = io.Copy(writer, readCloser) if err != nil { log.Printf("%s %s: error while writing template resource to output: %s", request.Method, request.URL, err) failer.ServeInternalServerError(writer, request) return } }
func (e *Editor) ServeHTTP(writer http.ResponseWriter, request *http.Request) { if e.isServeWriter(request) { e.serveWriter(writer, request) return } if e.isServeDeleter(request) { e.serveDeleter(writer, request) return } if e.isServeCreateUI(request) || e.isServeEditUI(request) { e.serveEditUI(writer, request) return } log.Printf("%s %s: method not allowed", request.Method, request.URL) failer.ServeMethodNotAllowed(writer, request) }
func (v *Viewer) serveNonGET(writer http.ResponseWriter, request *http.Request) { failer.ServeMethodNotAllowed(writer, request) }