forked from tangled.org/core
this repo has no description
at master 763 B view raw
1package xrpc 2 3import ( 4 "encoding/json" 5 "net/http" 6 7 "tangled.sh/tangled.sh/core/api/tangled" 8 xrpcerr "tangled.sh/tangled.sh/core/xrpc/errors" 9) 10 11func (x *Xrpc) Owner(w http.ResponseWriter, r *http.Request) { 12 owner := x.Config.Server.Owner 13 if owner == "" { 14 writeError(w, xrpcerr.OwnerNotFoundError, http.StatusInternalServerError) 15 return 16 } 17 18 response := tangled.Owner_Output{ 19 Owner: owner, 20 } 21 22 w.Header().Set("Content-Type", "application/json") 23 if err := json.NewEncoder(w).Encode(response); err != nil { 24 x.Logger.Error("failed to encode response", "error", err) 25 writeError(w, xrpcerr.NewXrpcError( 26 xrpcerr.WithTag("InternalServerError"), 27 xrpcerr.WithMessage("failed to encode response"), 28 ), http.StatusInternalServerError) 29 return 30 } 31}