<commit_before>package natsgw

import "encoding/json"

func (srv *Server) application() {
	srv.subscribe("ari.applications.all", func(_ string, _ []byte, reply Reply) {
		ax, err := srv.upstream.Application.List()
		if err != nil {
			reply(nil, err)
			return
		}

		var apps []string
		for _, a := range ax {
			apps = append(apps, a.ID())
		}

		reply(apps, nil)
	})

	srv.subscribe("ari.applications.data.*", func(subj string, _ []byte, reply Reply) {
		name := subj[len("ari.applications.data."):]
		data, err := srv.upstream.Application.Data(name)
		reply(data, err)
	})

	srv.subscribe("ari.applications.subscribe.*", func(subj string, data []byte, reply Reply) {
		name := subj[len("ari.applications.subscribe."):]

		var eventSource string
		if err := json.Unmarshal(data, &eventSource); err != nil {
			reply(nil, &decodingError{subj, err})
			return
		}

		err := srv.upstream.Application.Subscribe(name, eventSource)
		reply(nil, err)
	})

	srv.subscribe("ari.applications.unsubscribe.*", func(subj string, data []byte, reply Reply) {
		name := subj[len("ari.applications.unsubscribe."):]

		var eventSource string
		if err := json.Unmarshal(data, &eventSource); err != nil {
			reply(nil, &decodingError{subj, err})
			return
		}

		err := srv.upstream.Application.Unsubscribe(name, eventSource)
		reply(nil, err)
	})
}
<commit_msg>Revert "natsgw - update application to use '*' wildcards'"<commit_after>package natsgw

import "encoding/json"

func (srv *Server) application() {
	srv.subscribe("ari.applications.all", func(_ string, _ []byte, reply Reply) {
		ax, err := srv.upstream.Application.List()
		if err != nil {
			reply(nil, err)
			return
		}

		var apps []string
		for _, a := range ax {
			apps = append(apps, a.ID())
		}

		reply(apps, nil)
	})

	srv.subscribe("ari.applications.data.>", func(subj string, _ []byte, reply Reply) {
		name := subj[len("ari.applications.data."):]
		data, err := srv.upstream.Application.Data(name)
		reply(data, err)
	})

	srv.subscribe("ari.applications.subscribe.>", func(subj string, data []byte, reply Reply) {
		name := subj[len("ari.applications.subscribe."):]

		var eventSource string
		if err := json.Unmarshal(data, &eventSource); err != nil {
			reply(nil, &decodingError{subj, err})
			return
		}

		err := srv.upstream.Application.Subscribe(name, eventSource)
		reply(nil, err)
	})

	srv.subscribe("ari.applications.unsubscribe.>", func(subj string, data []byte, reply Reply) {
		name := subj[len("ari.applications.unsubscribe."):]

		var eventSource string
		if err := json.Unmarshal(data, &eventSource); err != nil {
			reply(nil, &decodingError{subj, err})
			return
		}

		err := srv.upstream.Application.Unsubscribe(name, eventSource)
		reply(nil, err)
	})
}

{'fraction_non_alphanumeric': 0.16489945155393054, 'fraction_numerical': 0.0, 'mean_word_length': 4.142857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3193912', 'n_tokens_mistral': 1057, 'n_tokens_neox': 953, 'n_words': 210}