go-http-peering/chi/mount.go

19 lines
563 B
Go
Raw Normal View History

2019-02-03 20:56:58 +01:00
package chi
import (
2019-02-22 17:35:49 +01:00
"crypto/rsa"
peering "forge.cadoles.com/Cadoles/go-http-peering"
"forge.cadoles.com/Cadoles/go-http-peering/server"
2019-02-03 20:56:58 +01:00
"github.com/go-chi/chi"
)
2019-02-22 17:35:49 +01:00
func Mount(r chi.Router, store peering.Store, key *rsa.PublicKey, funcs ...server.OptionFunc) {
r.Post(peering.AdvertisePath, server.AdvertiseHandler(store, key, funcs...))
2019-02-03 20:56:58 +01:00
r.Group(func(r chi.Router) {
2019-02-22 17:35:49 +01:00
r.Use(server.Authenticate(store, key, funcs...))
2019-02-03 20:56:58 +01:00
r.Post(peering.UpdatePath, server.UpdateHandler(store, funcs...))
r.Post(peering.PingPath, server.PingHandler(store, funcs...))
})
}