api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package api exposes HTTP API for bot service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Addr - HTTP server address.
	Addr string

	// ReadTimeout - HTTP server read timeout.
	ReadTimeout time.Duration

	// RequestTimeout - HTTP request timeout.
	RequestTimeout time.Duration
}

type Error

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

func WrapError

func WrapError(err error, kind ErrorKind, msg string) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorKind

type ErrorKind int
const (
	InvalidRequestDataError ErrorKind = iota
	HandlerFailedError
)

type Handler

type Handler interface {
	Call(ctx context.Context, req Request) error
}

type Request

type Request struct {
	ChatID  types.ChatID
	Payload map[string]string
}

type Service

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

func NewService

func NewService(cfg Config, handlers map[string]Handler) *Service

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

func (*Service) Stop

func (s *Service) Stop(ctx context.Context) error

Jump to

Keyboard shortcuts

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