mirror of
https://github.com/aykhans/bsky-feedgen.git
synced 2025-07-17 21:34:00 +00:00
🦋
This commit is contained in:
24
pkg/api/response/text.go
Normal file
24
pkg/api/response/text.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package response
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aykhans/bsky-feedgen/pkg/logger"
|
||||
)
|
||||
|
||||
func Text(w http.ResponseWriter, statusCode int, content []byte) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(statusCode)
|
||||
if _, err := w.Write(content); err != nil {
|
||||
logger.Log.Error("Failed to write text response", "error", err)
|
||||
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
func Text404(w http.ResponseWriter) {
|
||||
Text(w, 404, []byte("Not found"))
|
||||
}
|
||||
|
||||
func Text500(w http.ResponseWriter) {
|
||||
Text(w, 500, []byte("Internal server error"))
|
||||
}
|
Reference in New Issue
Block a user