ws

package
v1.3.0-pre1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2019 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package ws provides the JsonWs and XmlWs facilities which support JSON and XML web services.

This facility is documented in detail at http://granitic.io/1.0/ref/web-services

Web-services

Enabling the JsonWs or XmlWs facility allows the creation of web service endpoints where inbound and outbound data is automatically converted from and to JSON/XML.

An endpoint is created by adding an instance of handler.WsHandler with a corresponding implementation of handler.WsPostProcessor (generally referred to as handler logic) to your component definition file. For example:

"createRecordLogic": {
  "type": "inventory.CreateRecordLogic"
},

"createRecordHandler": {
  "type": "handler.WsHandler",
  "HTTPMethod": "POST",
  "Logic": "ref:createRecordLogic",
  "PathPattern": "^/record$",
}

See the ws and ws/handler package documentation for more information.

JSON

If JsonWs is enabled, any requests to a registered endpoint will have their request body parsed as JSON and any response rendered as JSON. This is handled with Go's built-in json package.

Many aspects of the parsing and rendering process (including content types, formatting of errors, pretty-printing and camel-case mapping) is configurable. Refer to http://granitic.io/1.0/ref/json for more details.

XML

Once the XmlWs facility is enabled, requests to an endpoint will, by default, be parsed as XML and rendered using user defined templates. Refer to http://granitic.io/1.0/ref/xml#templates for more details.

Alternatively, the XmlWs facility can be configured to automatically render responses as XML using Go's built-in XML marshalling components by setting the following configuration in your application's configuration files:

{
  "XmlWs": {
	"ResponseMode": "MARSHAL"
  }
}

Refer to http://granitic.io/1.0/ref/xml#marshalled for more information.

Many aspects of the parsing and rendering process (including content types and formatting of errors) is configurable. Refer to http://granitic.io/1.0/ref/xml for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonWsFacilityBuilder added in v1.1.0

type JsonWsFacilityBuilder struct {
}

Creates the components required to support the JsonWs facility and adds them the IoC container.

func (*JsonWsFacilityBuilder) BuildAndRegister added in v1.1.0

See FacilityBuilder.BuildAndRegister

func (*JsonWsFacilityBuilder) DependsOnFacilities added in v1.1.0

func (fb *JsonWsFacilityBuilder) DependsOnFacilities() []string

See FacilityBuilder.DependsOnFacilities

func (*JsonWsFacilityBuilder) FacilityName added in v1.1.0

func (fb *JsonWsFacilityBuilder) FacilityName() string

See FacilityBuilder.FacilityName

type XmlWsFacilityBuilder added in v1.1.0

type XmlWsFacilityBuilder struct {
}

Creates the components required to support the XmlWs facility and adds them the IoC container.

func (*XmlWsFacilityBuilder) BuildAndRegister added in v1.1.0

See FacilityBuilder.BuildAndRegister

func (*XmlWsFacilityBuilder) DependsOnFacilities added in v1.1.0

func (fb *XmlWsFacilityBuilder) DependsOnFacilities() []string

See FacilityBuilder.DependsOnFacilities

func (*XmlWsFacilityBuilder) FacilityName added in v1.1.0

func (fb *XmlWsFacilityBuilder) FacilityName() string

See FacilityBuilder.FacilityName

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL