Skip to content

Sepuka/vkbotserver

Repository files navigation

vkbotserver

Build Go Report Card

There is a server-bot for vk.com

Usage

  1. Add server as a dependency in your Gopkg.toml
[[constraint]]
  name = "github.com/sepuka/vkbotserver"
  version = "v0.0.2"
  1. Instance server
var handlers = []Executor{
    message.NewConfirmation(cfg.Server)
}

var handlerMap = make(message.HandlerMap, len(handlers))

for _, cmd := range handlers {
    msgName = cmd.(fmt.Stringer).String()
    handlerMap[msgName] = cmd.(message.Executor)
}

var simpleHandler = func (handler message.Executor, req *domain.Request, resp http.ResponseWriter) error {
    return handler.Exec(req, resp)
}

var server = server.NewSocketServer(cfg.Server, handlerMap, simpleHandler), nil
  1. Run and listen incoming requests
server.Listen()

Nginx settings

Bellow the example of the web-server config

        location ~^/your_postfix/ {
                include         fastcgi_params;
                fastcgi_pass    unix:/var/run/SOME_PATH/server.sock;
                access_log      /var/log/nginx/APP_access.log;
                error_log       /var/log/nginx/APP_error.log;
        }

Where fastcgi-pass param is a socket file which path you've written in the config config.socket.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published