From 85f8e84bd5799091a5af972828495eb244379adb Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Mon, 9 Nov 2020 13:44:42 -0500 Subject: [PATCH] Rename (*ResponseWriter).SetMimetype to SetMediaType --- fs.go | 4 ++-- server.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs.go b/fs.go index e44556c..c4cf3d3 100644 --- a/fs.go +++ b/fs.go @@ -33,7 +33,7 @@ func (fsh fsHandler) Respond(w *ResponseWriter, r *Request) { // Detect mimetype ext := path.Ext(p) mimetype := mime.TypeByExtension(ext) - w.SetMimetype(mimetype) + w.SetMediaType(mimetype) // Copy file to response writer io.Copy(w, f) } @@ -72,7 +72,7 @@ func ServeFile(w *ResponseWriter, fs FS, name string) { // Detect mimetype ext := path.Ext(name) mimetype := mime.TypeByExtension(ext) - w.SetMimetype(mimetype) + w.SetMediaType(mimetype) // Copy file to response writer io.Copy(w, f) } diff --git a/server.go b/server.go index 449f88d..6cc98f3 100644 --- a/server.go +++ b/server.go @@ -262,7 +262,7 @@ type ResponseWriter struct { b *bufio.Writer bodyAllowed bool wroteHeader bool - mimetype string + mediatype string } func newResponseWriter(conn net.Conn) *ResponseWriter { @@ -301,10 +301,10 @@ func (w *ResponseWriter) WriteStatus(status Status) { w.WriteHeader(status, status.Message()) } -// SetMimetype sets the mimetype that will be written for a successful response. +// SetMediaType sets the media type that will be written for a successful response. // If the mimetype is not set, it will default to "text/gemini". -func (w *ResponseWriter) SetMimetype(mimetype string) { - w.mimetype = mimetype +func (w *ResponseWriter) SetMediaType(mediatype string) { + w.mediatype = mediatype } // Write writes the response body. @@ -315,11 +315,11 @@ func (w *ResponseWriter) SetMimetype(mimetype string) { // with StatusSuccess and the mimetype set in SetMimetype. func (w *ResponseWriter) Write(b []byte) (int, error) { if !w.wroteHeader { - mimetype := w.mimetype - if mimetype == "" { - mimetype = "text/gemini" + mediatype := w.mediatype + if mediatype == "" { + mediatype = "text/gemini" } - w.WriteHeader(StatusSuccess, mimetype) + w.WriteHeader(StatusSuccess, mediatype) } if !w.bodyAllowed { return 0, ErrBodyNotAllowed