Documentation ¶
Overview ¶
Package api holds the models for the API Definition. On this package you can also find the default errors, handlers, loaders and repositories.
Index ¶
- Variables
- type APISpecRepository
- type Controller
- type Definition
- type Loader
- type MongoAPISpecRepository
- func (r *MongoAPISpecRepository) Add(definition *Definition) error
- func (r *MongoAPISpecRepository) FindAll() ([]*Definition, error)
- func (r *MongoAPISpecRepository) FindByID(id string) (*Definition, error)
- func (r *MongoAPISpecRepository) FindByListenPath(path string) (*Definition, error)
- func (r *MongoAPISpecRepository) Remove(id string) error
- type RateLimitMeta
- type Spec
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAPIDefinitionNotFound is used when the api was not found in the datastore ErrAPIDefinitionNotFound = errors.New(http.StatusNotFound, "api definition not found") // ErrDBContextNotSet is used when the database request context is not set ErrDBContextNotSet = errors.New(http.StatusInternalServerError, "DB context was not set for this request") )
Functions ¶
This section is empty.
Types ¶
type APISpecRepository ¶
type APISpecRepository interface { FindAll() ([]*Definition, error) FindByID(id string) (*Definition, error) Add(app *Definition) error Remove(id string) error }
APISpecRepository defines the behaviour of a country repository
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is the api rest controller
func NewController ¶
func NewController(loader *Loader) *Controller
NewController creates a new instance of Controller
func (*Controller) DeleteBy ¶
func (u *Controller) DeleteBy() http.HandlerFunc
func (*Controller) Get ¶
func (u *Controller) Get() http.HandlerFunc
func (*Controller) GetBy ¶
func (u *Controller) GetBy() http.HandlerFunc
func (*Controller) Post ¶
func (u *Controller) Post() http.HandlerFunc
func (*Controller) PutBy ¶
func (u *Controller) PutBy() http.HandlerFunc
type Definition ¶
type Definition struct { ID bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty" valid:"required"` CreatedAt time.Time `bson:"created_at" json:"created_at" valid:"-"` UpdatedAt time.Time `bson:"updated_at" json:"updated_at" valid:"-"` Name string `bson:"name" json:"name" valid:"required"` Slug string `bson:"slug" json:"slug"` Active bool `bson:"active" json:"active"` UseBasicAuth bool `bson:"use_basic_auth" json:"use_basic_auth"` Domain string `bson:"domain" json:"domain"` Proxy *proxy.Definition `bson:"proxy" json:"proxy" valid:"required"` AllowedIPs []string `mapstructure:"allowed_ips" bson:"allowed_ips" json:"allowed_ips"` UseOauth2 bool `bson:"use_oauth2" json:"use_oauth2"` OAuthServerID bson.ObjectId `bson:"oauth_server_id" json:"oauth_server_id"` RateLimit RateLimitMeta `bson:"rate_limit" json:"rate_limit" valid:"required"` CorsMeta cors.Meta `bson:"cors_meta" json:"cors_meta" valid:"cors_meta"` }
Definition Represents an API that you want to proxy
func NewDefinition ¶
func NewDefinition() *Definition
NewDefinition creates a new API Definition with default values
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is responsible for loading all apis form a datastore and configure them in a register
func NewLoader ¶
func NewLoader(register proxy.Register, store store.Store, accessor *middleware.DatabaseAccessor, manager *oauth.Manager, debug bool) *Loader
NewLoader creates a new instance of the api manager
func (*Loader) RegisterApi ¶
func (*Loader) RegisterApis ¶
RegisterApis load application middleware
type MongoAPISpecRepository ¶
type MongoAPISpecRepository struct {
// contains filtered or unexported fields
}
MongoAPISpecRepository represents a mongodb repository
func NewMongoAppRepository ¶
func NewMongoAppRepository(db *mgo.Database) (*MongoAPISpecRepository, error)
NewMongoAppRepository creates a mongo country repo
func (*MongoAPISpecRepository) Add ¶
func (r *MongoAPISpecRepository) Add(definition *Definition) error
Add adds a country to the repository
func (*MongoAPISpecRepository) FindAll ¶
func (r *MongoAPISpecRepository) FindAll() ([]*Definition, error)
FindAll fetches all the countries available
func (*MongoAPISpecRepository) FindByID ¶
func (r *MongoAPISpecRepository) FindByID(id string) (*Definition, error)
FindByID find a country by the iso2code provided
func (*MongoAPISpecRepository) FindByListenPath ¶
func (r *MongoAPISpecRepository) FindByListenPath(path string) (*Definition, error)
FindByListenPath searches an existing Proxy definition by its listen_path
func (*MongoAPISpecRepository) Remove ¶
func (r *MongoAPISpecRepository) Remove(id string) error
Remove removes a country from the repository
type RateLimitMeta ¶
type RateLimitMeta struct { Enabled bool `bson:"enabled" json:"enabled"` Limit string `bson:"limit" json:"limit"` }
RateLimitMeta holds configuration for a rate limit