Get Started
Setup
Otito provides a free and easy to use REST API that allows you programmatically access our services. Alongside this, we also provide SDKs in multiple languages for easy and stress-free integrations to your existing or new products. This gives you the option of either using an officially provided SDK/middleware or rolling out your own version directly via the API
go get -u -v github.com/ayinke-llc/otito-go-middleware
go get -u -v github.com/ayinke-llc/otito-go
Usage
handler, err := otitoMiddleware.New(otitoMiddleware.WithAPIKey(config.Global().Otito.Key),
otitoMiddleware.WithAppIDFn(func(r *http.Request) string {
orga, ok := r.Context().Value(orgCtx).(*otito.Organisation)
if !ok {
return ""
}
// return the app id for the current user
return orga.Metadata.OtitoAppID
}),
otitoMiddleware.WithFilterFn(func(r *http.Request) bool {
// skip all routes with auth in the url path
return !strings.Contains(r.URL.Path, "auth")
}),
// use the cloudflare strategy to get the right user IP
otitoMiddleware.WithIPStrategy(otitoMiddleware.CloudflareStrategy),
// batch all requests in 10s to Otito
otitoMiddleware.WithNumberOfMessagesBeforePublishing(10))
if err != nil {
panic(err.Error())
}
// this implements http.Handler so you can use in any of your favorite frameworks
// this could be an example
router.Use(handler.Handler)