home: github.com/shurcooL/home/http Index | Examples | Files

package http

import "github.com/shurcooL/home/http"

Package http contains service implementations over HTTP.

Index

Examples

Package Files

doc.go issues.go reactions.go users.go

type Issues Uses

type Issues struct {
    // contains filtered or unexported fields
}

Issues implements issues.Service remotely over HTTP. Use NewIssues for creation, zero value of Issues is unfit for use.

Code:

issuesClient := httpapi.NewIssues("http", "localhost:8080")

// Now you can use any of issuesClient methods.

func NewIssues Uses

func NewIssues(scheme, host string) *Issues

NewIssues creates a client that implements issues.Service remotely over HTTP. scheme and host can be empty strings to target local service.

func (*Issues) Count Uses

func (i *Issues) Count(ctx context.Context, repo issues.RepoSpec, opt issues.IssueListOptions) (uint64, error)

Code:

count, err := issuesClient.Count(context.Background(), issues.RepoSpec{URI: "example.org/repo"}, issues.IssueListOptions{
    State: issues.StateFilter(issues.AllStates),
})
if err != nil {
    log.Fatalln(err)
}

printJSON(count)

Output:

1

func (*Issues) Create Uses

func (*Issues) Create(_ context.Context, repo issues.RepoSpec, issue issues.Issue) (issues.Issue, error)

func (*Issues) CreateComment Uses

func (*Issues) CreateComment(_ context.Context, repo issues.RepoSpec, id uint64, comment issues.Comment) (issues.Comment, error)

func (*Issues) Edit Uses

func (*Issues) Edit(_ context.Context, repo issues.RepoSpec, id uint64, ir issues.IssueRequest) (issues.Issue, []issues.Event, error)

func (*Issues) EditComment Uses

func (i *Issues) EditComment(ctx context.Context, repo issues.RepoSpec, id uint64, cr issues.CommentRequest) (issues.Comment, error)

func (*Issues) Get Uses

func (*Issues) Get(_ context.Context, repo issues.RepoSpec, id uint64) (issues.Issue, error)

func (*Issues) List Uses

func (i *Issues) List(ctx context.Context, repo issues.RepoSpec, opt issues.IssueListOptions) ([]issues.Issue, error)

Code:

is, err := issuesClient.List(context.Background(), issues.RepoSpec{URI: "example.org/repo"}, issues.IssueListOptions{
    State: issues.StateFilter(issues.OpenState),
})
if err != nil {
    log.Fatalln(err)
}

printJSON(is)

Output:

[
	{
		"ID": 1,
		"State": "open",
		"Title": "Sample title",
		"Labels": null,
		"User": {
			"ID": 1,
			"Domain": "example.org",
			"Elsewhere": null,
			"Login": "gopher",
			"Name": "Sample Gopher",
			"Email": "gopher@example.org",
			"AvatarURL": "",
			"HTMLURL": "",
			"CreatedAt": "0001-01-01T00:00:00Z",
			"UpdatedAt": "0001-01-01T00:00:00Z",
			"SiteAdmin": false
		},
		"CreatedAt": "2016-09-24T22:00:50.642521756Z",
		"Edited": null,
		"Body": "",
		"Reactions": null,
		"Editable": false,
		"Replies": 2
	}
]

func (*Issues) ListComments Uses

func (i *Issues) ListComments(ctx context.Context, repo issues.RepoSpec, id uint64, opt *issues.ListOptions) ([]issues.Comment, error)

Code:

is, err := issuesClient.ListComments(context.Background(), issues.RepoSpec{URI: "example.org/repo"}, 1, nil)
if err != nil {
    log.Fatalln(err)
}

printJSON(is)

Output:

[
	{
		"ID": 0,
		"User": {
			"ID": 1,
			"Domain": "example.org",
			"Elsewhere": null,
			"Login": "gopher",
			"Name": "Sample Gopher",
			"Email": "gopher@example.org",
			"AvatarURL": "",
			"HTMLURL": "",
			"CreatedAt": "0001-01-01T00:00:00Z",
			"UpdatedAt": "0001-01-01T00:00:00Z",
			"SiteAdmin": false
		},
		"CreatedAt": "2016-09-24T22:00:50.642521756Z",
		"Edited": null,
		"Body": "Sample body.",
		"Reactions": [
			{
				"Reaction": "grinning",
				"Users": [
					{
						"ID": 1,
						"Domain": "example.org",
						"Elsewhere": null,
						"Login": "gopher",
						"Name": "Sample Gopher",
						"Email": "gopher@example.org",
						"AvatarURL": "",
						"HTMLURL": "",
						"CreatedAt": "0001-01-01T00:00:00Z",
						"UpdatedAt": "0001-01-01T00:00:00Z",
						"SiteAdmin": false
					}
				]
			},
			{
				"Reaction": "+1",
				"Users": [
					{
						"ID": 2,
						"Domain": "example.org",
						"Elsewhere": null,
						"Login": "2@example.org",
						"Name": "",
						"Email": "",
						"AvatarURL": "https://secure.gravatar.com/avatar?d=mm\u0026f=y\u0026s=96",
						"HTMLURL": "",
						"CreatedAt": "0001-01-01T00:00:00Z",
						"UpdatedAt": "0001-01-01T00:00:00Z",
						"SiteAdmin": false
					},
					{
						"ID": 1,
						"Domain": "example.org",
						"Elsewhere": null,
						"Login": "gopher",
						"Name": "Sample Gopher",
						"Email": "gopher@example.org",
						"AvatarURL": "",
						"HTMLURL": "",
						"CreatedAt": "0001-01-01T00:00:00Z",
						"UpdatedAt": "0001-01-01T00:00:00Z",
						"SiteAdmin": false
					},
					{
						"ID": 3,
						"Domain": "example.org",
						"Elsewhere": null,
						"Login": "3@example.org",
						"Name": "",
						"Email": "",
						"AvatarURL": "https://secure.gravatar.com/avatar?d=mm\u0026f=y\u0026s=96",
						"HTMLURL": "",
						"CreatedAt": "0001-01-01T00:00:00Z",
						"UpdatedAt": "0001-01-01T00:00:00Z",
						"SiteAdmin": false
					}
				]
			},
			{
				"Reaction": "mushroom",
				"Users": [
					{
						"ID": 3,
						"Domain": "example.org",
						"Elsewhere": null,
						"Login": "3@example.org",
						"Name": "",
						"Email": "",
						"AvatarURL": "https://secure.gravatar.com/avatar?d=mm\u0026f=y\u0026s=96",
						"HTMLURL": "",
						"CreatedAt": "0001-01-01T00:00:00Z",
						"UpdatedAt": "0001-01-01T00:00:00Z",
						"SiteAdmin": false
					}
				]
			}
		],
		"Editable": true
	},
	{
		"ID": 1,
		"User": {
			"ID": 2,
			"Domain": "example.org",
			"Elsewhere": null,
			"Login": "2@example.org",
			"Name": "",
			"Email": "",
			"AvatarURL": "https://secure.gravatar.com/avatar?d=mm\u0026f=y\u0026s=96",
			"HTMLURL": "",
			"CreatedAt": "0001-01-01T00:00:00Z",
			"UpdatedAt": "0001-01-01T00:00:00Z",
			"SiteAdmin": false
		},
		"CreatedAt": "2016-10-02T12:31:50.813167602Z",
		"Edited": null,
		"Body": "Sample reply.",
		"Reactions": null,
		"Editable": false
	},
	{
		"ID": 2,
		"User": {
			"ID": 1,
			"Domain": "example.org",
			"Elsewhere": null,
			"Login": "gopher",
			"Name": "Sample Gopher",
			"Email": "gopher@example.org",
			"AvatarURL": "",
			"HTMLURL": "",
			"CreatedAt": "0001-01-01T00:00:00Z",
			"UpdatedAt": "0001-01-01T00:00:00Z",
			"SiteAdmin": false
		},
		"CreatedAt": "2016-10-02T18:51:14.250725508Z",
		"Edited": {
			"By": {
				"ID": 1,
				"Domain": "example.org",
				"Elsewhere": null,
				"Login": "gopher",
				"Name": "Sample Gopher",
				"Email": "gopher@example.org",
				"AvatarURL": "",
				"HTMLURL": "",
				"CreatedAt": "0001-01-01T00:00:00Z",
				"UpdatedAt": "0001-01-01T00:00:00Z",
				"SiteAdmin": false
			},
			"At": "2016-10-02T18:57:47.938813179Z"
		},
		"Body": "Sample another reply.",
		"Reactions": null,
		"Editable": true
	}
]

func (*Issues) ListEvents Uses

func (*Issues) ListEvents(_ context.Context, repo issues.RepoSpec, id uint64, opt *issues.ListOptions) ([]issues.Event, error)

type Reactions Uses

type Reactions struct{}

Reactions implements reactions.Service remotely over HTTP.

func (Reactions) Get Uses

func (Reactions) Get(ctx context.Context, uri string, id string) ([]reactions.Reaction, error)

func (Reactions) List Uses

func (Reactions) List(ctx context.Context, uri string) (map[string][]reactions.Reaction, error)

func (Reactions) Toggle Uses

func (Reactions) Toggle(ctx context.Context, uri string, id string, tr reactions.ToggleRequest) ([]reactions.Reaction, error)

type Users Uses

type Users struct{}

Users implements users.Service remotely over HTTP.

func (Users) Edit Uses

func (Users) Edit(_ context.Context, er users.EditRequest) (users.User, error)

func (Users) Get Uses

func (Users) Get(_ context.Context, user users.UserSpec) (users.User, error)

func (Users) GetAuthenticated Uses

func (Users) GetAuthenticated(ctx context.Context) (users.User, error)

func (Users) GetAuthenticatedSpec Uses

func (Users) GetAuthenticatedSpec(ctx context.Context) (users.UserSpec, error)

Package http imports 10 packages (graph) and is imported by 1 packages. Updated 2017-02-10. Refresh now. Tools for package owners.