aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2020-11-09 13:44:42 -0500
committerAdnan Maolood <[email protected]>2020-11-09 13:44:42 -0500
commit85f8e84bd5799091a5af972828495eb244379adb (patch)
tree4a558aa110ae6bb4696e61821b805628d0d3b000
parentAdd (*KnownHosts).SetOutput function (diff)
downloadgo-gemini-85f8e84bd5799091a5af972828495eb244379adb.tar.xz
go-gemini-85f8e84bd5799091a5af972828495eb244379adb.zip
Rename (*ResponseWriter).SetMimetype to SetMediaType
-rw-r--r--fs.go4
-rw-r--r--server.go16
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