postapi

package module
v0.0.0-...-8be55dc Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: Apache-2.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

POST API

build postapi

Install go-spirit command before you build postapi

Install go-spirit command
go get github.com/go-spirit/go-spirit
go install github.com/go-spirit/go-spirit
Build
> go-spirit build --config build.conf
make sure the components are already registered
> ./postapi list components
- function: github.com/go-spirit/spirit/component/function.newComponentFunc
- mns: github.com/go-spirit/spirit/component/mns.NewMNSComponent
- postapi: github.com/spirit-component/postapi.NewPostAPI
run components
> ./postapi run --config configs/postapi.conf

postapi.conf example


include "configs/secret.conf"

components.mns.endpoint {

	access-key-id = ${aliyun.access-key-id}
	access-key-secret = ${aliyun.access-key-secret}
	endpoint = ${aliyun.endpoint}

	queues {
		api-call-error {}
		api-call-back {}
	}
}

components.postapi.external.grapher.driver = default

components.postapi.external.grapher.default = {

	todo-task-new {
		name  = "todo.task.new"
		graph = {
			error {
				to-queue {
					seq = 1
					url = "spirit://actors/fbp/mns/endpoint?queue=api-call-error"
				}

				response {
					seq = 2
					url = "spirit://actors/fbp/postapi/external?action=callback"
				}
			}

			entrypoint {
				to-queue-new-task {
					seq = 1
					url = "spirit://actors/fbp/mns/endpoint?queue=todo-task-new"
				}

				to-todo {
					seq = 2
					url = "spirit://actors/fbp/examples-todo/todo?action=new"
				}

				to-callback-queue {
					seq = 3
					url = "spirit://actors/fbp/mns/endpoint?queue=api-call-back"
				}

				response {
					seq = 4
					url = "spirit://actors/fbp/postapi/external?action=callback"
				}
			}
		}
	}
}

Documentation

Index

Constants

View Source
const (
	XApi        = "X-Api"
	XApiBatch   = "X-Api-Batch"
	XApiTimeout = "X-Api-Timeout"
)

Variables

This section is empty.

Functions

func NewPostAPI

func NewPostAPI(alias string, opts ...component.Option) (srv component.Component, err error)

Types

type GraphProvider

type GraphProvider interface {
	WithFallback(config.Configuration) error
	Query(apiName string) (map[string]*protocol.Graph, bool)
}

type PostAPI

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

func (*PostAPI) Alias

func (p *PostAPI) Alias() string

func (*PostAPI) Document

func (p *PostAPI) Document() doc.Document

func (*PostAPI) Route

func (*PostAPI) Start

func (p *PostAPI) Start() error

func (*PostAPI) Stop

func (p *PostAPI) Stop() error

type PostAPIResponse

type PostAPIResponse struct {
	API            string          `json:"-"`
	Code           int64           `json:"code"`
	ErrorId        string          `json:"error_id,omitempty"`
	ErrorNamespace string          `json:"error_namespace,omitempty"`
	Message        string          `json:"message"`
	Result         json.RawMessage `json:"result"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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