diff options
| author | Adnan Maolood <[email protected]> | 2020-11-09 13:44:42 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2020-11-09 13:44:42 -0500 |
| commit | 85f8e84bd5799091a5af972828495eb244379adb (patch) | |
| tree | 4a558aa110ae6bb4696e61821b805628d0d3b000 | |
| parent | Add (*KnownHosts).SetOutput function (diff) | |
| download | go-gemini-85f8e84bd5799091a5af972828495eb244379adb.tar.xz go-gemini-85f8e84bd5799091a5af972828495eb244379adb.zip | |
Rename (*ResponseWriter).SetMimetype to SetMediaType
| -rw-r--r-- | fs.go | 4 | ||||
| -rw-r--r-- | server.go | 16 |
2 files changed, 10 insertions, 10 deletions
@@ -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) } @@ -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 |