Documentation ¶
Index ¶
- Constants
- type Controller
- type NJTransit
- type Provider
- type Repository
- func (r *Repository) CreateOne(provider Provider) bool
- func (r *Repository) DeleteAll(uuids []apimongo.UUID) (bool, error)
- func (r *Repository) DeleteOne(uuid apimongo.UUID) (bool, error)
- func (r *Repository) GetAll() ([]Provider, error)
- func (r *Repository) GetOne(uuid apimongo.UUID) (*Provider, error)
Constants ¶
View Source
const ( // GetPath path for HTTP GET Method which to query for providers GetPath = "/providers" // SingleGetPath path for HTTP GET Method to query for a single provider SingleGetPath = GetPath + "/" + uuidPattern // CreatePath path for HTTP POST Method to create a new provider CreatePath = "/providers" // DeletePath path for HTTP DELETE Method to delete a provider DeletePath = "/providers/" + uuidPattern )
View Source
const (
// NJTransitType one of supported Provider types
NJTransitType = "NJTransit"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct { Repository *Repository // contains filtered or unexported fields }
Controller handles all provider related requests.
func NewController ¶
func NewController(repo *Repository) Controller
NewController creates new Providers controller
func (*Controller) Create ¶
func (c *Controller) Create(w http.ResponseWriter, r *http.Request)
Create creates a new provider.
func (*Controller) Delete ¶
func (c *Controller) Delete(w http.ResponseWriter, r *http.Request)
Delete deletes provider.
func (*Controller) Get ¶
func (c *Controller) Get(w http.ResponseWriter, r *http.Request)
Get returns one provider.
func (*Controller) GetAll ¶
func (c *Controller) GetAll(w http.ResponseWriter, r *http.Request)
GetAll returns all providers.
type NJTransit ¶
type NJTransit struct { OrigStationCode *string `json:"orig_station_code" bson:"orig_station_code"` DestStationCode *string `json:"dest_station_code" bson:"dest_station_code"` }
NJTransit model that represents NJ Transit provider
type Provider ¶
type Provider struct { ID mongo.UUID `json:"_id" bson:"_id"` Type *string `json:"type" bson:"type"` NJTransit *NJTransit `json:"njtransit,omitempty" bson:"njtransit,omitempty"` }
Provider model that represents providers
type Repository ¶
Repository to access providers store
func (*Repository) CreateOne ¶
func (r *Repository) CreateOne(provider Provider) bool
CreateOne creates new provider for specified params
func (*Repository) DeleteAll ¶
func (r *Repository) DeleteAll(uuids []apimongo.UUID) (bool, error)
DeleteAll deletes providers with IDs and returns true if any record was removed
func (*Repository) DeleteOne ¶
func (r *Repository) DeleteOne(uuid apimongo.UUID) (bool, error)
DeleteOne deletes provider with ID and returns true if record was removed
func (*Repository) GetAll ¶
func (r *Repository) GetAll() ([]Provider, error)
GetAll returns all providers
Click to show internal directories.
Click to hide internal directories.