Rename ResponseWriter.MediaType to SetMediaType
This commit is contained in:
parent
420f01da2a
commit
2c64db3863
2
fs.go
2
fs.go
@ -51,7 +51,7 @@ func serveContent(w ResponseWriter, name string, content io.Reader) {
|
|||||||
// Detect mimetype from file extension
|
// Detect mimetype from file extension
|
||||||
ext := path.Ext(name)
|
ext := path.Ext(name)
|
||||||
mimetype := mime.TypeByExtension(ext)
|
mimetype := mime.TypeByExtension(ext)
|
||||||
w.MediaType(mimetype)
|
w.SetMediaType(mimetype)
|
||||||
io.Copy(w, content)
|
io.Copy(w, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
response.go
10
response.go
@ -160,18 +160,18 @@ func (r *Response) Write(w io.Writer) error {
|
|||||||
// A ResponseWriter may not be used after the Handler.ServeGemini method
|
// A ResponseWriter may not be used after the Handler.ServeGemini method
|
||||||
// has returned.
|
// has returned.
|
||||||
type ResponseWriter interface {
|
type ResponseWriter interface {
|
||||||
// MediaType sets the media type that will be sent by Write for a
|
// SetMediaType sets the media type that will be sent by Write for a
|
||||||
// successful response. If no media type is set, a default of
|
// successful response. If no media type is set, a default of
|
||||||
// "text/gemini; charset=utf-8" will be used.
|
// "text/gemini; charset=utf-8" will be used.
|
||||||
//
|
//
|
||||||
// Setting the media type after a call to Write or WriteHeader has
|
// Setting the media type after a call to Write or WriteHeader has
|
||||||
// no effect.
|
// no effect.
|
||||||
MediaType(string)
|
SetMediaType(string)
|
||||||
|
|
||||||
// Write writes the data to the connection as part of a Gemini response.
|
// Write writes the data to the connection as part of a Gemini response.
|
||||||
//
|
//
|
||||||
// If WriteHeader has not yet been called, Write calls WriteHeader with
|
// If WriteHeader has not yet been called, Write calls WriteHeader with
|
||||||
// StatusSuccess and the media type set in MediaType before writing the data.
|
// StatusSuccess and the media type set in SetMediaType before writing the data.
|
||||||
// If no media type was set, Write uses a default media type of
|
// If no media type was set, Write uses a default media type of
|
||||||
// "text/gemini; charset=utf-8".
|
// "text/gemini; charset=utf-8".
|
||||||
Write([]byte) (int, error)
|
Write([]byte) (int, error)
|
||||||
@ -181,7 +181,7 @@ type ResponseWriter interface {
|
|||||||
//
|
//
|
||||||
// If WriteHeader is not called explicitly, the first call to Write
|
// If WriteHeader is not called explicitly, the first call to Write
|
||||||
// will trigger an implicit call to WriteHeader with a successful
|
// will trigger an implicit call to WriteHeader with a successful
|
||||||
// status code and the media type set in MediaType.
|
// status code and the media type set in SetMediaType.
|
||||||
//
|
//
|
||||||
// The provided code must be a valid Gemini status code.
|
// The provided code must be a valid Gemini status code.
|
||||||
// The provided meta must not be longer than 1024 bytes.
|
// The provided meta must not be longer than 1024 bytes.
|
||||||
@ -210,7 +210,7 @@ func newResponseWriter(w io.Writer) *responseWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *responseWriter) MediaType(mediatype string) {
|
func (w *responseWriter) SetMediaType(mediatype string) {
|
||||||
w.mediatype = mediatype
|
w.mediatype = mediatype
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ type timeoutWriter struct {
|
|||||||
timedOut bool
|
timedOut bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *timeoutWriter) MediaType(mediatype string) {
|
func (w *timeoutWriter) SetMediaType(mediatype string) {
|
||||||
w.mu.Lock()
|
w.mu.Lock()
|
||||||
defer w.mu.Unlock()
|
defer w.mu.Unlock()
|
||||||
w.mediatype = mediatype
|
w.mediatype = mediatype
|
||||||
|
Loading…
Reference in New Issue
Block a user