ws

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2017 License: Apache-2.0 Imports: 10 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

type JSONWsFacilityBuilder struct {
}

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

func (*JSONWsFacilityBuilder) BuildAndRegister

See FacilityBuilder.BuildAndRegister

func (*JSONWsFacilityBuilder) DependsOnFacilities

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

See FacilityBuilder.DependsOnFacilities

func (*JSONWsFacilityBuilder) FacilityName

func (fb *JSONWsFacilityBuilder) FacilityName() string

See FacilityBuilder.FacilityName

type XMLWsFacilityBuilder

type XMLWsFacilityBuilder struct {
}

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

func (*XMLWsFacilityBuilder) BuildAndRegister

See FacilityBuilder.BuildAndRegister

func (*XMLWsFacilityBuilder) DependsOnFacilities

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

See FacilityBuilder.DependsOnFacilities

func (*XMLWsFacilityBuilder) FacilityName

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