// MarshalServer marshals server into JSON.
MarshalServer marshals server into JSON.
// MarshalServer marshals server into JSON .
func (*teleportServerMarshaler) MarshalServer(s Server, opts ...MarshalOption) ([]byte, error) {
	if err := s.CheckAndSetDefaults(); err != nil {
		return nil, trace.Wrap(err)
	}
	cfg, err := CollectOptions(opts)
	if err != nil {
		return nil, trace.Wrap(err)
	}
	switch server := s.(type) {
	case *ServerV2:
		if !cfg.PreserveResourceID {
			copy := *server
			copy.SetResourceID(0)
			server = &copy
		}
		return utils.FastMarshal(server)
	default:
		return nil, trace.BadParameter("unrecognized server version %T", s)
	}
}
func ( * teleportServerMarshaler ) MarshalServer ( s Server , opts ... MarshalOption ) ( [ ] byte , error ) { if err := s . CheckAndSetDefaults ( ) ; err != nil { return nil , trace . Wrap ( err ) } cfg , err := CollectOptions ( opts ) if err != nil { return nil , trace . Wrap ( err ) } switch server := s . ( type ) { case * ServerV2 : if ! cfg . PreserveResourceID { copy := * server copy . SetResourceID ( 0 ) server = & copy } return utils . FastMarshal ( server ) default : return nil , trace . BadParameter ( " " , s ) } }
MarshalServer marshals server into JSON.
MarshalServer marshals server into JSON .
// avoid modifying the original object // to prevent unexpected data races