gate

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2020 License: MIT Imports: 5 Imported by: 0

README

Gate

Gate posts a message in Slack and LINE.

Installation

go get github.com/kaneshin/gate/cmd/...

Setup

Gate loads its configuration in ~/.config/gate/config.yml as a default. You need to create it then setup your channels' configuration:

---
default_target: 'slack.incoming.channel-1'

env:
  host: 'http://127.0.0.1'
  port: 8080

slack:
  incoming:
    channel-1: '[YOUR-INCOMING-URL]'
    channel-2: '[YOUR-INCOMING-URL]'

line:
  notify:
    service-1: '[YOUR-ACCESS-TOKEN]'

Usage

gate

Run the gate server

$ gate

# gate -config=/path/to/config.yml
gatecli
$ echo "foobar" | gatecli

# echo "foobar" | gatecli -config=/path/to/config.yml -target=slack.incomiong.channel-2

License

The MIT License (MIT)

Author

Shintaro Kaneko kaneshin0120@gmail.com

Documentation

Index

Constants

View Source
const Version = "v1.2.1"

Version represents gate's semantic version.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// The HTTP client to use when sending requests.
	HTTPClient *http.Client

	AccessToken string
}

Config provides service configuration for service.

func NewConfig

func NewConfig() *Config

NewConfig returns a pointer of new Config objects.

func (*Config) WithAccessToken

func (c *Config) WithAccessToken(token string) *Config

WithAccessToken sets a access token value to verify service returning a Config pointer for chaining.

func (*Config) WithHTTPClient

func (c *Config) WithHTTPClient(client *http.Client) *Config

WithHTTPClient sets a config HTTPClient value returning a Config pointer for chaining.

type LINENotifyService

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

LINENotifyService is a slack incoming webhook service.

func NewLINENotifyService

func NewLINENotifyService(config *Config) *LINENotifyService

NewLINENotifyService returns a new LINENotifyService.

func (LINENotifyService) Post

func (s LINENotifyService) Post(contentType string, body io.Reader) (*http.Response, error)

Post posts a payload to LINE.

func (LINENotifyService) PostMessagePayload added in v1.2.0

func (s LINENotifyService) PostMessagePayload(payload MessagePayload) (*http.Response, error)

PostMessagePayload posts a message payload to LINE.

type MessagePayload added in v1.2.0

type MessagePayload struct {
	Message string `json:"message"`
}

MessagePayload represents a message payload.

type SlackIncomingService

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

SlackIncomingService is a slack incoming webhook service.

func NewSlackIncomingService

func NewSlackIncomingService(config *Config) *SlackIncomingService

NewSlackIncomingService returns a new SlackIncomingService.

func (SlackIncomingService) Post

func (s SlackIncomingService) Post(contentType string, body io.Reader) (*http.Response, error)

Post posts a payload to slack.

func (SlackIncomingService) PostTextPayload added in v1.2.0

func (s SlackIncomingService) PostTextPayload(payload TextPayload) (*http.Response, error)

PostTextPayload posts a text payload to slack.

func (*SlackIncomingService) WithBaseURL

func (s *SlackIncomingService) WithBaseURL(baseURL string) *SlackIncomingService

WithBaseURL sets a base url value returning a service pointer for chaining.

type TextPayload added in v1.2.0

type TextPayload struct {
	Text string `json:"text"`
}

TextPayload represents a text payload.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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