BREAKING CHANGE: Rename http module to webutils

This commit is contained in:
Melody Becker 2025-04-09 13:57:01 +02:00
parent 9b6664399f
commit 4612ee993e
Signed by: mstar
SSH key fingerprint: SHA256:9VAo09aaVNTWKzPW7Hq2LW+ox9OdwmTSHRoD4mlz1yI
5 changed files with 21 additions and 4 deletions

View file

@ -1,4 +1,4 @@
package http package webutils
import ( import (
"net/http" "net/http"

View file

@ -1,4 +1,4 @@
package http package webutils
import ( import (
"context" "context"

View file

@ -1,4 +1,4 @@
package http package webutils
import ( import (
"encoding/json" "encoding/json"

17
http/json.go Normal file
View file

@ -0,0 +1,17 @@
package webutils
import (
"encoding/json"
"fmt"
"net/http"
)
func SendJson(w http.ResponseWriter, data any) error {
encoded, err := json.Marshal(data)
if err != nil {
return err
}
w.Header().Add("Content-Type", "application/json")
fmt.Fprint(w, string(encoded))
return nil
}

View file

@ -1,4 +1,4 @@
package http package webutils
import ( import (
"net/http" "net/http"