parent
c41fca9c5a
commit
34bb137e7b
|
@ -1,18 +1,17 @@
|
||||||
package webserver
|
package webserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
queue "git.martyn.berlin/martyn/LEDController/internal/queue"
|
||||||
"github.com/gorilla/handlers"
|
"github.com/gorilla/handlers"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
queue "git.martyn.berlin/martyn/LEDController/internal/queue"
|
|
||||||
"golang.org/x/image/colornames"
|
"golang.org/x/image/colornames"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func HealthHandler(response http.ResponseWriter, request *http.Request) {
|
func HealthHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
|
@ -30,7 +29,7 @@ func RootHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
fmt.Fprint(response, "Not implemented")
|
fmt.Fprint(response, "Not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
var globalQueue chan queue.QueueItem;
|
var globalQueue chan queue.QueueItem
|
||||||
|
|
||||||
func PatternHandler(response http.ResponseWriter, request *http.Request) {
|
func PatternHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
vars := mux.Vars(request)
|
vars := mux.Vars(request)
|
||||||
|
@ -68,7 +67,7 @@ func ColourHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
e.Duration = 5000
|
e.Duration = 5000
|
||||||
}
|
}
|
||||||
var c queue.RGBcolor
|
var c queue.RGBcolor
|
||||||
for cn, cv := range(colornames.Map) {
|
for cn, cv := range colornames.Map {
|
||||||
if cn == strings.ToLower(vars["name"]) {
|
if cn == strings.ToLower(vars["name"]) {
|
||||||
c[0] = cv.R
|
c[0] = cv.R
|
||||||
c[1] = cv.G
|
c[1] = cv.G
|
||||||
|
@ -93,7 +92,7 @@ func FadeHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
e.Duration = 5000
|
e.Duration = 5000
|
||||||
}
|
}
|
||||||
var c queue.RGBcolor
|
var c queue.RGBcolor
|
||||||
for cn, cv := range(colornames.Map) {
|
for cn, cv := range colornames.Map {
|
||||||
if cn == strings.ToLower(vars["namefrom"]) {
|
if cn == strings.ToLower(vars["namefrom"]) {
|
||||||
c[0] = cv.R
|
c[0] = cv.R
|
||||||
c[1] = cv.G
|
c[1] = cv.G
|
||||||
|
@ -101,7 +100,7 @@ func FadeHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e.SeedColour = c
|
e.SeedColour = c
|
||||||
for cn, cv := range(colornames.Map) {
|
for cn, cv := range colornames.Map {
|
||||||
if cn == strings.ToLower(vars["nameto"]) {
|
if cn == strings.ToLower(vars["nameto"]) {
|
||||||
c[0] = cv.R
|
c[0] = cv.R
|
||||||
c[1] = cv.G
|
c[1] = cv.G
|
||||||
|
@ -132,7 +131,7 @@ func HandleHTTP(queueChannel chan queue.QueueItem, Port int) {
|
||||||
http.Handle("/", r)
|
http.Handle("/", r)
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Handler: loggedRouter,
|
Handler: loggedRouter,
|
||||||
Addr: "0.0.0.0:"+strconv.Itoa(Port),
|
Addr: "0.0.0.0:" + strconv.Itoa(Port),
|
||||||
WriteTimeout: 15 * time.Second,
|
WriteTimeout: 15 * time.Second,
|
||||||
ReadTimeout: 15 * time.Second,
|
ReadTimeout: 15 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue