types

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: Apache-2.0 Imports: 6 Imported by: 71

Documentation

Overview

Package types provides custom types to support CloudEvents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Allocate

func Allocate(obj interface{}) (asPtr interface{}, asValue reflect.Value)

Allocate allocates a new instance of type t and returns: asPtr is of type t if t is a pointer type and of type &t otherwise asValue is a Value of type t pointing to the same data as asPtr

Types

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp wraps time.Time to normalize the time layout to RFC3339. It is intended to enforce compliance with the CloudEvents spec for their definition of Timestamp. Custom marshal methods are implemented to ensure the outbound Timestamp is a string in the RFC3339 layout.

func ParseTimestamp

func ParseTimestamp(t string) *Timestamp

ParseTimestamp attempts to parse the given time assuming RFC3339 layout

func (*Timestamp) MarshalJSON

func (t *Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom json marshal method used when this type is marshaled using json.Marshal.

func (*Timestamp) MarshalXML

func (t *Timestamp) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements a custom xml marshal method used when this type is marshaled using xml.Marshal.

func (*Timestamp) String

func (t *Timestamp) String() string

String outputs the time using layout RFC3339.

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json unmarshal method used when this type is unmarshaled using json.Unmarshal.

func (*Timestamp) UnmarshalXML

func (t *Timestamp) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements the xml unmarshal method used when this type is unmarshaled using xml.Unmarshal.

type URLRef

type URLRef struct {
	url.URL
}

URLRef is a wrapper to url.URL. It is intended to enforce compliance with the CloudEvents spec for their definition of URI-Reference. Custom marshal methods are implemented to ensure the outbound URLRef object is is a flat string.

func ParseURLRef

func ParseURLRef(u string) *URLRef

ParseURLRef attempts to parse the given string as a URI-Reference.

func (URLRef) MarshalJSON

func (u URLRef) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom json marshal method used when this type is marshaled using json.Marshal.

func (URLRef) MarshalXML

func (u URLRef) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements a custom xml marshal method used when this type is marshaled using xml.Marshal.

func (*URLRef) String

func (u *URLRef) String() string

String returns the full string representation of the URI-Reference.

func (*URLRef) UnmarshalJSON

func (u *URLRef) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json unmarshal method used when this type is unmarshaled using json.Unmarshal.

func (*URLRef) UnmarshalXML

func (u *URLRef) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements the xml unmarshal method used when this type is unmarshaled using xml.Unmarshal.

Jump to

Keyboard shortcuts

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