Skip to content
Snippets Groups Projects
Commit 14d633f1 authored by Martin Iversen's avatar Martin Iversen
Browse files

Created gateway.go and configured enpoint for gateway POST payload

parent 70f8cbda
No related branches found
No related tags found
2 merge requests!59Working on mqtt broker, added in necessary mosuitto config and passsword file...,!57Working on mqtt broker, added in necessary mosuitto config and passsword file...
......@@ -46,6 +46,8 @@ func Handle() {
router.HandleFunc(baseURL+"/user", ProfileRequest).Queries("role", "{role}")
router.HandleFunc(baseURL+"/user", ProfileRequest)
router.HandleFunc(baseURL+"/gateway/input", GatewayRequest)
http.Handle("/", router)
log.Println(http.ListenAndServe(getPort(), nil))
}
......
package endpoints
import (
"encoding/json"
"net/http"
)
/**
Class gateway
The class wil handle all information regarding the cellular gateways in the system
......@@ -12,3 +17,13 @@ The class will contain the following functions:
Version 0.1
Last modified Martin Iversen
*/
func GatewayRequest(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
w.Header().Set("Access-Control-Allow-Headers", "Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers")
json.NewEncoder(w).Encode("Request sent to the gateway endpoint")
json.NewEncoder(w).Encode(r.Body)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment