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