forked from mirror/serenity
Fix render
This commit is contained in:
parent
1492b474cd
commit
5b5d3aac86
@ -104,7 +104,7 @@ func export(profileName string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
encoder := json.NewEncoder(os.Stdout)
|
encoder := json.NewEncoderContext(globalCtx, os.Stdout)
|
||||||
encoder.SetIndent("", " ")
|
encoder.SetIndent("", " ")
|
||||||
err = encoder.Encode(boxOptions)
|
err = encoder.Encode(boxOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2,7 +2,6 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -12,6 +11,7 @@ import (
|
|||||||
boxOption "github.com/sagernet/sing-box/option"
|
boxOption "github.com/sagernet/sing-box/option"
|
||||||
"github.com/sagernet/sing/common"
|
"github.com/sagernet/sing/common"
|
||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
|
"github.com/sagernet/sing/common/json"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/go-chi/cors"
|
"github.com/go-chi/cors"
|
||||||
@ -74,8 +74,7 @@ func (s *Server) render(writer http.ResponseWriter, request *http.Request) {
|
|||||||
s.accessLog(request, http.StatusNotFound, 0)
|
s.accessLog(request, http.StatusNotFound, 0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
metadata := M.Detect(request.Header.Get("User-Agent"))
|
options, err := profile.Render(M.Detect(request.Header.Get("User-Agent")))
|
||||||
options, err := profile.Render(metadata)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.logger.Error(E.Cause(err, "render options"))
|
s.logger.Error(E.Cause(err, "render options"))
|
||||||
render.Status(request, http.StatusInternalServerError)
|
render.Status(request, http.StatusInternalServerError)
|
||||||
@ -84,7 +83,7 @@ func (s *Server) render(writer http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
encoder := json.NewEncoder(&buffer)
|
encoder := json.NewEncoderContext(s.ctx, &buffer)
|
||||||
encoder.SetIndent("", " ")
|
encoder.SetIndent("", " ")
|
||||||
err = encoder.Encode(&options)
|
err = encoder.Encode(&options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user