# README
Joe Bot - HTTP Server
Providing HTTP integrations for Joe. https://github.com/go-joe/joe
This repository contains a module for the Joe Bot library.
Getting Started
This library is packaged as Go module. You can get it via:
go get github.com/go-joe/http-server
Example usage
In order to let your bot listen to HTTP requests you should pass the http.Server(…)
module when creating a new bot:
package main
import (
"github.com/go-joe/joe"
"github.com/go-joe/http-server"
)
func main() {
b := joe.New("example-bot",
joehttp.Server("localhost:12345"),
…
)
err := b.Run()
if err != nil {
b.Logger.Fatal(err.Error())
}
}
When the server receives a request, it will emit it to the bots brain as joehttp.RequestEvent
.
Built With
Contributing
If you want to hack on this repository, please read the short CONTRIBUTING.md guide first.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Friedrich Große - Initial work - fgrosse
See also the list of contributors who participated in this project.
License
This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.
# Functions
Server returns a joe Module that runs an HTTP server to receive HTTP requests and emit them as events.
WithLogger can be used to inject a different logger for the HTTP server.
WithReadTimeout sets the servers maximum duration for reading the entire HTTP request, including the body.
WithTimeouts sets both the read and write timeout of the HTTP server to the same given value.
WithTLS enables serving HTTP requests via TLS.
WithTLSConfig can be used in combination with the WithTLS(…) option to configure the HTTPS server.
WithTrustedHeader sets the name of the header from which client IPs will be populated.
WithWriteTimeout sets the servers maximum duration before timing out writes of the HTTP response.
# Structs
RequestEvent corresponds to an HTTP request that was received by the server.
# Type aliases
An Option is used to configure the HTTP server.