mirror of
https://github.com/spaytac/orbiter.git
synced 2026-01-22 06:34:41 +00:00
Add the ability to send post without content
This commit is contained in:
parent
b6f6cb3784
commit
d231b613ea
@ -79,6 +79,12 @@ scale it can call the outscaler to persist the right action
|
|||||||
curl -v -d '{"direction": true}' \
|
curl -v -d '{"direction": true}' \
|
||||||
http://localhost:8000/handle/infra_scale/docker
|
http://localhost:8000/handle/infra_scale/docker
|
||||||
```
|
```
|
||||||
|
Or if you prefer
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -v -X POST http://localhost:8000/handle/infra_scale/docker/up
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Autodetect
|
## Autodetect
|
||||||
The autodetect mode starts when you don't specify any configuration file.
|
The autodetect mode starts when you don't specify any configuration file.
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/gianarb/orbiter/autoscaler"
|
"github.com/gianarb/orbiter/autoscaler"
|
||||||
@ -21,6 +22,11 @@ type scaleRequest struct {
|
|||||||
func Handle(scalers autoscaler.Autoscalers) func(w http.ResponseWriter, r *http.Request) {
|
func Handle(scalers autoscaler.Autoscalers) func(w http.ResponseWriter, r *http.Request) {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var err error
|
var err error
|
||||||
|
requestDump, err := httputil.DumpRequest(r, true)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Println(string(requestDump))
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
decoder := json.NewDecoder(r.Body)
|
decoder := json.NewDecoder(r.Body)
|
||||||
var scaleRequest scaleRequest
|
var scaleRequest scaleRequest
|
||||||
@ -35,6 +41,16 @@ func Handle(scalers autoscaler.Autoscalers) func(w http.ResponseWriter, r *http.
|
|||||||
w.WriteHeader(406)
|
w.WriteHeader(406)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
directionByRoute, ok := vars["direction"]
|
||||||
|
if ok {
|
||||||
|
if directionByRoute == "up" {
|
||||||
|
scaleRequest.Direction = DIRECTION_UP
|
||||||
|
} else {
|
||||||
|
scaleRequest.Direction = DIRECTION_DOWN
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
serviceName, ok := vars["service_name"]
|
serviceName, ok := vars["service_name"]
|
||||||
if !ok {
|
if !ok {
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import (
|
|||||||
func GetRouter(core core.Core, eventChannel chan *logrus.Entry) *mux.Router {
|
func GetRouter(core core.Core, eventChannel chan *logrus.Entry) *mux.Router {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
r.HandleFunc("/handle/{autoscaler_name}/{service_name}", Handle(core.Autoscalers)).Methods("POST")
|
r.HandleFunc("/handle/{autoscaler_name}/{service_name}", Handle(core.Autoscalers)).Methods("POST")
|
||||||
|
r.HandleFunc("/handle/{autoscaler_name}/{service_name}/{direction}", Handle(core.Autoscalers)).Methods("POST")
|
||||||
r.HandleFunc("/autoscaler", AutoscalerList(core.Autoscalers)).Methods("GET")
|
r.HandleFunc("/autoscaler", AutoscalerList(core.Autoscalers)).Methods("GET")
|
||||||
r.HandleFunc("/health", Health()).Methods("GET")
|
r.HandleFunc("/health", Health()).Methods("GET")
|
||||||
r.HandleFunc("/events", Events(eventChannel)).Methods("GET")
|
r.HandleFunc("/events", Events(eventChannel)).Methods("GET")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user