api

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connect

type Connect struct{}

func (*Connect) Method

func (c *Connect) Method() string

type Created

type Created struct{}

func (*Created) Expect

func (c *Created) Expect() int

type Delete

type Delete struct{}

func (*Delete) Method

func (d *Delete) Method() string

type Endpoint

type Endpoint interface {
	Methoder
	Expecter
	Resourcer
}

An Endpoint encodes what method, status return code, and REST resource that that Endpoint responds to.

The pattern that implementors will see is that of declaring a struct that both implements this interface and can be JSON serialized to the expected input of that endpoint (if any).

An example implementation may be...

type UpdateBug struct {
	BugId      int `json:"-"` // This is not in the Bugzilla API, it is for building the resource
	api.Update
	api.Ok
	Assignee   string `json:"assignee"`
	Status     string `json:"status"`
	Resolution string `json:"resolution"`
	...
}

func (u *UpdateBug) Resource() string {
	return fmt.Sprintf("/bug/%d", u.BugId)
}

type Expecter

type Expecter interface {
	Expect() int
}

An Expecter returns the HTTP status code that signifies an successful response.

It is intended that consumers of this API embed the provided types in a declarative fashion. For example:

	type GetBug struct {
		...
		api.Ok
 }

type Get

type Get struct{}

func (*Get) Method

func (g *Get) Method() string
type Head struct{}

func (*Head) Method

func (h *Head) Method() string

type Methoder

type Methoder interface {
	Method() string
}

A Methoder returns the HTTP method that the target endpoint is listening on.

It is intended that consumers of this API embed the provided types in a declarative fashion. For example:

	type UpdateBug struct {
		...
		api.Update
 }

type Ok

type Ok struct{}

func (*Ok) Expect

func (ok *Ok) Expect() int

type Options

type Options struct{}

func (*Options) Method

func (o *Options) Method() string

type Patch

type Patch struct{}

func (*Patch) Method

func (p *Patch) Method() string

type Post

type Post struct{}

func (*Post) Method

func (p *Post) Method() string

type Put

type Put struct{}

func (*Put) Method

func (p *Put) Method() string

type Resourcer

type Resourcer interface {
	Resource() string
}

A Resourcer returns the REST API resource for accessing a given endpoint. The returned string should fulfill all paths BEYOND the base path and "rest" resource (proto>://<hostname>/rest).

E.G. If we are accessing a bug at "https://bugzilla-dev.allizom.org" then this method should return "/bug/<id>"

type Trace

type Trace struct{}

func (*Trace) Method

func (t *Trace) Method() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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