Beispiel #1
0
// initService sets up the service encoders, decoders and mux.
func initService(service *goa.Service) {
	if inited {
		return
	}
	inited = true

	// Setup encoders and decoders
	service.Encoder(goa.NewJSONEncoder, "application/json")
	service.Decoder(goa.NewJSONDecoder, "application/json")
	service.Decoder(goa.NewGobDecoder, "application/gob", "application/x-gob")
	service.Decoder(goa.NewXMLDecoder, "application/xml")

	// Setup default encoder and decoder
	service.Encoder(goa.NewJSONEncoder, "*/*")
	service.Decoder(goa.NewJSONDecoder, "*/*")
}
Beispiel #2
0
	"net/url"

	"golang.org/x/net/context"

	"github.com/goadesign/goa"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Service", func() {
	const appName = "foo"
	var s *goa.Service

	BeforeEach(func() {
		s = goa.New(appName)
		s.Decoder(goa.NewJSONDecoder, "*/*")
		s.Encoder(goa.NewJSONEncoder, "*/*")
	})

	Describe("New", func() {
		It("creates a service", func() {
			Ω(s).ShouldNot(BeNil())
		})

		It("initializes the service fields", func() {
			Ω(s.Name).Should(Equal(appName))
			Ω(s.Mux).ShouldNot(BeNil())
		})
	})

	Describe("NotFound", func() {