web provider post
ramify
This commit is contained in:
parent
8dabe42a8a
commit
f6d587b16a
4 changed files with 8 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Tortuous</title>
|
||||
<title>Ramify</title>
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
|
||||
|
@ -18,7 +18,7 @@
|
|||
<body>
|
||||
<nav class="navbar navbar-default" role="navigation">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="/html/">Tortuous</a>
|
||||
<a class="navbar-brand" href="/html/">Ramify</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse navbar-ex1-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
|
|
|
@ -144,7 +144,7 @@ func Invoke(any interface{}, name string, args ...interface{}) []reflect.Value {
|
|||
|
||||
func LoadFileConfig() *FileConfiguration {
|
||||
configuration := new(FileConfiguration)
|
||||
if _, err := toml.DecodeFile("tortuous.toml", configuration); err != nil {
|
||||
if _, err := toml.DecodeFile("ramify.toml", configuration); err != nil {
|
||||
log.Fatal("Error reading file:", err)
|
||||
}
|
||||
return configuration
|
|
@ -6,7 +6,7 @@ watch = true
|
|||
address = ":8010"
|
||||
|
||||
#[file]
|
||||
#filename = "tortuous.toml"
|
||||
#filename = "ramify.toml"
|
||||
#watch = true
|
||||
|
||||
[backends]
|
9
web.go
9
web.go
|
@ -11,7 +11,6 @@ import (
|
|||
"io/ioutil"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
var renderer = render.New()
|
||||
|
@ -33,12 +32,12 @@ func (provider *WebProvider) Provide(configurationChan chan<- *Configuration){
|
|||
configuration := new(Configuration)
|
||||
b, _ := ioutil.ReadAll(r.Body)
|
||||
err:= json.Unmarshal(b, configuration)
|
||||
log.Println(err)
|
||||
if (err!= nil && reflect.DeepEqual(new(Configuration), configuration)) {
|
||||
if (err == nil) {
|
||||
configurationChan <- configuration
|
||||
renderer.JSON(rw, http.StatusCreated, map[string]string{"result": "OK"})
|
||||
GetConfigHandler(rw, r)
|
||||
}else{
|
||||
renderer.JSON(rw, http.StatusBadRequest, map[string]string{"result": "error"})
|
||||
log.Printf("Error parsing configuration %+v\n", err)
|
||||
http.Error(rw, fmt.Sprintf("%+v", err), http.StatusBadRequest)
|
||||
}
|
||||
})))
|
||||
systemRouter.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("static/"))))
|
||||
|
|
Loading…
Reference in a new issue