posts

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceName = "posts"

ServiceName is the name of the service as defined in the design. This is the same value that is set in the endpoint request contexts under the ServiceKey key.

Variables

View Source
var MethodNames = [2]string{"register", "search"}

MethodNames lists the service method names as defined in the design. These are the same values that are set in the endpoint request contexts under the MethodKey key.

Functions

func MakeBadRequest

func MakeBadRequest(err error) *goa.ServiceError

MakeBadRequest builds a goa.ServiceError from an error.

func MakeInternal

func MakeInternal(err error) *goa.ServiceError

MakeInternal builds a goa.ServiceError from an error.

func MakeUnauthenticated

func MakeUnauthenticated(err error) *goa.ServiceError

MakeUnauthenticated builds a goa.ServiceError from an error.

func NewRegisterEndpoint

func NewRegisterEndpoint(s Service, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint

NewRegisterEndpoint returns an endpoint function that calls the method "register" of service "posts".

func NewSearchEndpoint

func NewSearchEndpoint(s Service) goa.Endpoint

NewSearchEndpoint returns an endpoint function that calls the method "search" of service "posts".

Types

type Auther

type Auther interface {
	// APIKeyAuth implements the authorization logic for the APIKey security scheme.
	APIKeyAuth(ctx context.Context, key string, schema *security.APIKeyScheme) (context.Context, error)
}

Auther defines the authorization functions to be implemented by the service.

type Client

type Client struct {
	RegisterEndpoint goa.Endpoint
	SearchEndpoint   goa.Endpoint
}

Client is the "posts" service client.

func NewClient

func NewClient(register, search goa.Endpoint) *Client

NewClient initializes a "posts" service client given the endpoints.

func (*Client) Register

func (c *Client) Register(ctx context.Context, p *RegisterPayload) (res int, err error)

Register calls the "register" endpoint of the "posts" service.

func (*Client) Search

func (c *Client) Search(ctx context.Context, p *SearchPayload) (res *SearchResult, err error)

Search calls the "search" endpoint of the "posts" service.

type Endpoints

type Endpoints struct {
	Register goa.Endpoint
	Search   goa.Endpoint
}

Endpoints wraps the "posts" service endpoints.

func NewEndpoints

func NewEndpoints(s Service) *Endpoints

NewEndpoints wraps the methods of the "posts" service with endpoints.

func (*Endpoints) Use

func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint)

Use applies the given middleware to all the "posts" service endpoints.

type PostOutput

type PostOutput struct {
	// Post's id
	ID string
	// Post's title
	Title string
	// Post's description
	Description string
}

type PostOutputCollection

type PostOutputCollection []*PostOutput

type PostParams

type PostParams struct {
	// Post's id
	ID *string
	// Post's title
	Title *string
	// Post's description
	Description *string
	// Post's body
	Body *string
}

type RegisterPayload

type RegisterPayload struct {
	// API key used to perform authorization
	Key   string
	Posts []*PostParams
}

RegisterPayload is the payload type of the posts service register method.

type SearchPayload

type SearchPayload struct {
	// search query
	Query string
	// page
	Page uint
	// results per page
	PageSize uint
}

search params

type SearchResult

type SearchResult struct {
	Posts     PostOutputCollection
	Page      uint
	TotalPage uint
}

SearchResult is the result type of the posts service search method.

type Service

type Service interface {
	// registers blog posts to be searched
	Register(context.Context, *RegisterPayload) (res int, err error)
	// search blog posts
	Search(context.Context, *SearchPayload) (res *SearchResult, err error)
}

Service is the posts service interface.

Jump to

Keyboard shortcuts

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