-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2021 Clivern. All rights reserved. | ||
// Use of this source code is governed by the MIT | ||
// license that can be found in the LICENSE file. | ||
|
||
package model | ||
|
||
import ( | ||
yaml "gopkg.in/yaml.v2" | ||
) | ||
|
||
// Configs type | ||
type Configs struct { | ||
App App `yaml:"app"` | ||
} | ||
|
||
// App type | ||
type App struct { | ||
Endpoints []Endpoints `yaml:"endpoints"` | ||
} | ||
|
||
// Endpoints type | ||
type Endpoints struct { | ||
Name string `yaml:"name"` | ||
Active bool `yaml:"active"` | ||
Proxy Proxy `yaml:"proxy"` | ||
} | ||
|
||
// Proxy type | ||
type Proxy struct { | ||
Upstreams Upstreams `yaml:"upstreams"` | ||
Methods []string `yaml:"methods"` | ||
Authentication Authentication `yaml:"authentication"` | ||
RateLimit RateLimit `yaml:"rate_limit"` | ||
CircuitBreaker CircuitBreaker `yaml:"circuit_breaker"` | ||
ListenPath string `yaml:"listen_path"` | ||
} | ||
|
||
// Authentication type | ||
type Authentication struct { | ||
Status bool `yaml:"status"` | ||
Methods []Methods `yaml:"methods"` | ||
} | ||
|
||
// Methods type | ||
type Methods struct { | ||
ID int `yaml:"id"` | ||
} | ||
|
||
// Upstreams type | ||
type Upstreams struct { | ||
Balancing string `yaml:"balancing"` | ||
Targets []Targets `yaml:"targets"` | ||
} | ||
|
||
// Targets type | ||
type Targets struct { | ||
Target string `yaml:"target"` | ||
} | ||
|
||
// RateLimit type | ||
type RateLimit struct { | ||
Status bool `yaml:"status"` | ||
} | ||
|
||
// CircuitBreaker type | ||
type CircuitBreaker struct { | ||
Status bool `yaml:"status"` | ||
} | ||
|
||
// LoadFromYAML update instance from YAML | ||
func (c *Configs) LoadFromYAML(data []byte) error { | ||
err := yaml.Unmarshal(data, &c) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters