Simple and lightweight Apache2 Config Detector and Parser
- none
All code examples are not handling any errors please keep that in mind
This function will detect all configs save it into a
[]string array and returns the []string
package main
import(
"github.com/dbzmelvin/go-apachetizer"
"fmt"
)
func main(){
list, _ := apachetizer.VHostConfDetector("./etc/apache2/sites-available")
fmt.Printf("This is your list: %s", list)
}
This function will parse the given config file, you have to pass an io.Reader
package main
import(
"github.com/dbzmelvin/go-apachetizer"
"fmt"
"os"
"encoding/json"
)
func main(){
Reader, _ := os.Open("./etc/apache2/testconfig-le-ssl.conf") //io.Reader
config, _ := apachetizer.VHostConfParser(Reader) //Parse the config
jsonEncoded, _ := json.Marshal(config) //Encode the []string array to json []byte array
fmt.Println(string(jsonEncoded)) //Print the []byte array as string
}