mirror of
https://github.com/miniflux/v2.git
synced 2025-08-11 17:51:01 +00:00
refactor(misc): make use of type constraints where possible
This commit is contained in:
parent
078eb39db9
commit
f3052eb8ed
2 changed files with 3 additions and 3 deletions
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// OK creates a new HTML response with a 200 status code.
|
// OK creates a new HTML response with a 200 status code.
|
||||||
func OK(w http.ResponseWriter, r *http.Request, body interface{}) {
|
func OK[T []byte | string](w http.ResponseWriter, r *http.Request, body T) {
|
||||||
builder := response.New(w, r)
|
builder := response.New(w, r)
|
||||||
builder.WithHeader("Content-Type", "text/html; charset=utf-8")
|
builder.WithHeader("Content-Type", "text/html; charset=utf-8")
|
||||||
builder.WithHeader("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store")
|
builder.WithHeader("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store")
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// OK writes a standard XML response with a status 200 OK.
|
// OK writes a standard XML response with a status 200 OK.
|
||||||
func OK(w http.ResponseWriter, r *http.Request, body interface{}) {
|
func OK[T []byte | string](w http.ResponseWriter, r *http.Request, body T) {
|
||||||
builder := response.New(w, r)
|
builder := response.New(w, r)
|
||||||
builder.WithHeader("Content-Type", "text/xml; charset=utf-8")
|
builder.WithHeader("Content-Type", "text/xml; charset=utf-8")
|
||||||
builder.WithBody(body)
|
builder.WithBody(body)
|
||||||
|
@ -18,7 +18,7 @@ func OK(w http.ResponseWriter, r *http.Request, body interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attachment forces the XML document to be downloaded by the web browser.
|
// Attachment forces the XML document to be downloaded by the web browser.
|
||||||
func Attachment(w http.ResponseWriter, r *http.Request, filename string, body interface{}) {
|
func Attachment[T []byte | string](w http.ResponseWriter, r *http.Request, filename string, body T) {
|
||||||
builder := response.New(w, r)
|
builder := response.New(w, r)
|
||||||
builder.WithHeader("Content-Type", "text/xml; charset=utf-8")
|
builder.WithHeader("Content-Type", "text/xml; charset=utf-8")
|
||||||
builder.WithAttachment(filename)
|
builder.WithAttachment(filename)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue