mirror of
https://github.com/1f349/violet.git
synced 2024-11-22 03:11:44 +00:00
20 lines
349 B
Go
20 lines
349 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
a1 = []byte("<a href=\"")
|
||
|
a2 = []byte("\">")
|
||
|
a3 = []byte("</a>.\n")
|
||
|
)
|
||
|
|
||
|
func FastRedirect(rw http.ResponseWriter, req *http.Request, url string, code int) {
|
||
|
rw.Header().Add("Location", url)
|
||
|
rw.WriteHeader(code)
|
||
|
if req.Method == http.MethodGet {
|
||
|
_, _ = rw.Write([]byte(http.StatusText(code)))
|
||
|
}
|
||
|
}
|