github.com/dannyzhou2015/migrate/v4@v4.15.2/source/httpfs/driver.go (about)

     1  package httpfs
     2  
     3  import (
     4  	"errors"
     5  	"net/http"
     6  
     7  	"github.com/dannyzhou2015/migrate/v4/source"
     8  )
     9  
    10  // driver is a migration source driver for reading migrations from
    11  // http.FileSystem instances. It implements source.Driver interface and can be
    12  // used as a migration source for the main migrate library.
    13  type driver struct {
    14  	PartialDriver
    15  }
    16  
    17  // New creates a new migrate source driver from a http.FileSystem instance and a
    18  // relative path to migration files within the virtual FS.
    19  func New(fs http.FileSystem, path string) (source.Driver, error) {
    20  	var d driver
    21  	if err := d.Init(fs, path); err != nil {
    22  		return nil, err
    23  	}
    24  	return &d, nil
    25  }
    26  
    27  // Open completes the implementetion of source.Driver interface. Other methods
    28  // are implemented by the embedded PartialDriver struct.
    29  func (d *driver) Open(url string) (source.Driver, error) {
    30  	return nil, errors.New("Open() cannot be called on the httpfs passthrough driver")
    31  }