Skip to content

Commit

Permalink
fix some indent in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
fzerorubigd committed Jul 29, 2015
1 parent b5d5bfc commit d6ea495
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ layer type is supported.
File layer is the basic one.

```go
l := onion.NewFileLayer("/path/to/the/file.ext")
l := onion.NewFileLayer("/path/to/the/file.ext")
```

the onion package only support for json extension by itself, and there is toml
Expand All @@ -36,18 +36,18 @@ and call the RegisterLoader function with your loader object
Folder layer is much like file layer but it get a folder and search for the
first file with tha specific name and supported extension
```go
l := onion.NewFolderLayer("/path/to/folder", "filename")
l := onion.NewFolderLayer("/path/to/folder", "filename")
```
the file name part is WHITOUT extension. library check for supported loader
extension in that folder and return the first one.


### ENV Loader
### ENV layer

The other layer is env layer. this layer accept a whitelist of env variables and
use them as value .
The other layer is env layer. this layer accept a white list of env variables and
use them as key for the env variables.
```go
l := onion.NewEnvLayer("PORT", "STATIC_ROOT", "NEXT")
l := onion.NewEnvLayer("PORT", "STATIC_ROOT", "NEXT")
```
this layer currently dose not support nested variables.

Expand All @@ -56,32 +56,32 @@ this layer currently dose not support nested variables.

After adding layers to config, its easy to get the config values.
```go
o := onion.New()
o.AddLayer(l1)
o.AddLayer(l2)
o := onion.New()
o.AddLayer(l1)
o.AddLayer(l2)

o.GetString("key", "default")
o.GetBool("anotherkey", true)
o.GetString("key", "default")
o.GetBool("anotherkey", true)

o.GetInt("worker.count", 10) // Nested value
o.GetInt("worker.count", 10) // Nested value
```
library also support for mapping data to a structure. define your structure :
```go
type MyStruct struct {
Key1 string
Key2 int
type MyStruct struct {
Key1 string
Key2 int

Key3 bool `onion:"boolkey"` // struct tag is supported to change the name
Key3 bool `onion:"boolkey"` // struct tag is supported to change the name

Other struct {
Nested string
}
Other struct {
Nested string
}
}

o := onion.New()
// Add layers.....
c := MyStruct{}
o.GetStruct("prefix", &c)
o := onion.New()
// Add layers.....
c := MyStruct{}
o.GetStruct("prefix", &c)
```
the the c.Key1 is equal to o.GetString("prefix.key1", c.Key1) , note that the
value before calling this function is used as default value, when the type is
Expand Down

0 comments on commit d6ea495

Please sign in to comment.