Files
glauth/v2/pkg/server/embed.go
timmy 1549d440b7 Update ldap server implementation to github.com/gwelch-contegix/ldaps
Update ldap client implementation to github.com/go-ldap/ldap/v3
Add contexts to all relevant functions eg NewHandler
Provide backwards compatibility for sql handlers
2026-08-30 21:10:02 -07:00

31 lines
831 B
Go

//go:build embed
package server
import (
"context"
"errors"
"github.com/glauth/glauth/v2/pkg/embed"
"github.com/glauth/glauth/v2/pkg/handler"
)
func NewEmbed(ctx context.Context, opts ...handler.Option) (handler.Handler, error) {
var (
// Erase the type so we can dynamically check at runtime
handlerFunc any = embed.NewHandler
ok bool
legacyHandler func(...handler.Option) handler.Handler
newHandler func(context.Context, ...handler.Option) handler.Handler
)
newHandler, ok = handlerFunc.(func(context.Context, ...handler.Option) handler.Handler)
if ok {
return newHandler(ctx, opts...), nil
}
legacyHandler, ok = handlerFunc.(func(...handler.Option) handler.Handler)
if ok {
return legacyHandler(opts...), nil
}
return nil, errors.New("GLAuth failed to load the embedded plugin")
}