33 lines
780 B
Go
33 lines
780 B
Go
package send
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"git.akyoto.dev/go/server"
|
|
)
|
|
|
|
func Text(ctx server.Context, body string) error {
|
|
ctx.Response().SetHeader("Content-Type", "text/plain")
|
|
return ctx.String(body)
|
|
}
|
|
|
|
func CSS(ctx server.Context, body string) error {
|
|
ctx.Response().SetHeader("Content-Type", "text/css")
|
|
return ctx.String(body)
|
|
}
|
|
|
|
func JS(ctx server.Context, body string) error {
|
|
ctx.Response().SetHeader("Content-Type", "text/javascript")
|
|
return ctx.String(body)
|
|
}
|
|
|
|
func JSON(ctx server.Context, object any) error {
|
|
ctx.Response().SetHeader("Content-Type", "application/json")
|
|
return json.NewEncoder(ctx.Response()).Encode(object)
|
|
}
|
|
|
|
func HTML(ctx server.Context, body string) error {
|
|
ctx.Response().SetHeader("Content-Type", "text/html")
|
|
return ctx.String(body)
|
|
}
|