27 lines
636 B
Go
27 lines
636 B
Go
package app
|
|
|
|
import "net/http"
|
|
|
|
func handleTransportSingBoxProfileCardGet(w http.ResponseWriter, _ *http.Request, id string) {
|
|
singBoxProfilesMu.Lock()
|
|
st := loadSingBoxProfilesState()
|
|
singBoxProfilesMu.Unlock()
|
|
|
|
idx := findSingBoxProfileIndex(st.Items, id)
|
|
if idx < 0 {
|
|
writeJSON(w, http.StatusNotFound, SingBoxProfilesResponse{
|
|
OK: false,
|
|
Code: singBoxProfileCodeNotFound,
|
|
Message: "not found",
|
|
})
|
|
return
|
|
}
|
|
item := st.Items[idx]
|
|
writeJSON(w, http.StatusOK, SingBoxProfilesResponse{
|
|
OK: true,
|
|
Message: "ok",
|
|
ActiveProfileID: st.ActiveProfileID,
|
|
Item: &item,
|
|
})
|
|
}
|