apply/make Travis's json-format branch prototype to work with latest restructured master; added StatusCode to JSONOutput server-function contract

This commit is contained in:
amykang2020
2017-09-07 02:00:22 -07:00
committed by Denis Makogon
parent b8d7154747
commit b6b9b55ca9
10 changed files with 250 additions and 19 deletions

View File

@@ -36,6 +36,7 @@ type Protocol string
const (
Default Protocol = models.FormatDefault
HTTP Protocol = models.FormatHTTP
JSON Protocol = models.FormatJSON
Empty Protocol = ""
)
@@ -45,6 +46,8 @@ func (p *Protocol) UnmarshalJSON(b []byte) error {
*p = Default
case HTTP:
*p = HTTP
case JSON:
*p = JSON
default:
return errInvalidProtocol
}
@@ -57,6 +60,8 @@ func (p Protocol) MarshalJSON() ([]byte, error) {
return []byte(Default), nil
case HTTP:
return []byte(HTTP), nil
case JSON:
return []byte(JSON), nil
}
return nil, errInvalidProtocol
}
@@ -67,6 +72,8 @@ func New(p Protocol, in io.Writer, out io.Reader) ContainerIO {
switch p {
case HTTP:
return &HTTPProtocol{in, out}
case JSON:
return &JSONProtocol{in, out}
case Default, Empty:
return &DefaultProtocol{}
}