web provider post

ramify
This commit is contained in:
emile 2015-09-09 09:16:56 +02:00
parent 8dabe42a8a
commit f6d587b16a
4 changed files with 8 additions and 9 deletions

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Tortuous</title> <title>Ramify</title>
<!-- Bootstrap --> <!-- Bootstrap -->
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
@ -18,7 +18,7 @@
<body> <body>
<nav class="navbar navbar-default" role="navigation"> <nav class="navbar navbar-default" role="navigation">
<div class="navbar-header"> <div class="navbar-header">
<a class="navbar-brand" href="/html/">Tortuous</a> <a class="navbar-brand" href="/html/">Ramify</a>
</div> </div>
<div class="collapse navbar-collapse navbar-ex1-collapse"> <div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">

View file

@ -144,7 +144,7 @@ func Invoke(any interface{}, name string, args ...interface{}) []reflect.Value {
func LoadFileConfig() *FileConfiguration { func LoadFileConfig() *FileConfiguration {
configuration := new(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) log.Fatal("Error reading file:", err)
} }
return configuration return configuration

View file

@ -6,7 +6,7 @@ watch = true
address = ":8010" address = ":8010"
#[file] #[file]
#filename = "tortuous.toml" #filename = "ramify.toml"
#watch = true #watch = true
[backends] [backends]

9
web.go
View file

@ -11,7 +11,6 @@ import (
"io/ioutil" "io/ioutil"
"encoding/json" "encoding/json"
"log" "log"
"reflect"
) )
var renderer = render.New() var renderer = render.New()
@ -33,12 +32,12 @@ func (provider *WebProvider) Provide(configurationChan chan<- *Configuration){
configuration := new(Configuration) configuration := new(Configuration)
b, _ := ioutil.ReadAll(r.Body) b, _ := ioutil.ReadAll(r.Body)
err:= json.Unmarshal(b, configuration) err:= json.Unmarshal(b, configuration)
log.Println(err) if (err == nil) {
if (err!= nil && reflect.DeepEqual(new(Configuration), configuration)) {
configurationChan <- configuration configurationChan <- configuration
renderer.JSON(rw, http.StatusCreated, map[string]string{"result": "OK"}) GetConfigHandler(rw, r)
}else{ }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/")))) systemRouter.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("static/"))))