-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add free endpoints * Documentation Update * Add backend to the server block * Add more context to error message no quoting due to (escaped) json log Co-authored-by: Alex Schneider <alex.schneider@sevenval.com> Co-authored-by: Marcel Ludwig <marcel.ludwig@avenga.com>
- Loading branch information
3 people
authored
Jan 27, 2021
1 parent
4b25ece
commit a23cfa7
Showing
14 changed files
with
309 additions
and
71 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
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
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 |
---|---|---|
@@ -1,13 +1,51 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/hashicorp/hcl/v2" | ||
"github.com/hashicorp/hcl/v2/gohcl" | ||
) | ||
|
||
var _ Inline = &Server{} | ||
|
||
// Server represents the HCL <server> block. | ||
type Server struct { | ||
AccessControl []string `hcl:"access_control,optional"` | ||
DisableAccessControl []string `hcl:"disable_access_control,optional"` | ||
API *Api `hcl:"api,block"` | ||
BasePath string `hcl:"base_path,optional"` | ||
ErrorFile string `hcl:"error_file,optional"` | ||
Files *Files `hcl:"files,block"` | ||
Hosts []string `hcl:"hosts,optional"` | ||
Name string `hcl:"name,label"` | ||
Spa *Spa `hcl:"spa,block"` | ||
AccessControl []string `hcl:"access_control,optional"` | ||
DisableAccessControl []string `hcl:"disable_access_control,optional"` | ||
API *Api `hcl:"api,block"` | ||
Backend string `hcl:"backend,optional"` | ||
BasePath string `hcl:"base_path,optional"` | ||
Endpoints Endpoints `hcl:"endpoint,block"` | ||
ErrorFile string `hcl:"error_file,optional"` | ||
Files *Files `hcl:"files,block"` | ||
Hosts []string `hcl:"hosts,optional"` | ||
Name string `hcl:"name,label"` | ||
Remain hcl.Body `hcl:",remain"` | ||
Spa *Spa `hcl:"spa,block"` | ||
} | ||
|
||
func (s Server) Body() hcl.Body { | ||
return s.Remain | ||
} | ||
|
||
func (s Server) Reference() string { | ||
return s.Backend | ||
} | ||
|
||
func (s Server) Schema(inline bool) *hcl.BodySchema { | ||
if !inline { | ||
schema, _ := gohcl.ImpliedBodySchema(s) | ||
return schema | ||
} | ||
|
||
type Inline struct { | ||
Backend *Backend `hcl:"backend,block"` | ||
} | ||
schema, _ := gohcl.ImpliedBodySchema(&Inline{}) | ||
|
||
// The Server contains a backend reference, backend block is not allowed. | ||
if s.Backend != "" { | ||
schema.Blocks = nil | ||
} | ||
|
||
return newBackendSchema(schema, s.Body()) | ||
} |
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
Oops, something went wrong.