Add database custom interface functions

This commit is contained in:
Vladimir Stoilov 2023-06-02 11:41:38 +03:00 committed by Daniel
parent e033cff403
commit df62abdf1b
5 changed files with 166 additions and 128 deletions

View file

@ -224,6 +224,17 @@ func RegisterEndpoint(e Endpoint) error {
return nil
}
func GetEndpointByPath(path string) (*Endpoint, error) {
endpointsLock.Lock()
defer endpointsLock.Unlock()
endpoint, ok := endpoints[path]
if !ok {
return nil, fmt.Errorf("no registered endpoint on path: %q", path)
}
return endpoint, nil
}
func (e *Endpoint) check() error {
// Check path.
if strings.TrimSpace(e.Path) == "" {