mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-20 07:19:20 +01:00
feat(tf): add middleware for state
This commit is contained in:
parent
f151ee7b89
commit
80d5b4a276
@ -100,10 +100,12 @@ func Route() *mux.Router {
|
||||
publicWebHookRouter.Use(StoreMiddleware, JSONMiddleware)
|
||||
publicWebHookRouter.Path("/integrations/{integration_alias}").HandlerFunc(ReceiveIntegration).Methods("POST", "GET", "OPTIONS")
|
||||
|
||||
publicWebHookRouter.Path("/terraform/{alias}").HandlerFunc(getTerraformState).Methods("GET")
|
||||
publicWebHookRouter.Path("/terraform/{alias}").HandlerFunc(addTerraformState).Methods("POST")
|
||||
publicWebHookRouter.Path("/terraform/{alias}").HandlerFunc(lockTerraformState).Methods("LOCK")
|
||||
publicWebHookRouter.Path("/terraform/{alias}").HandlerFunc(unlockTerraformState).Methods("UNLOCK")
|
||||
terraformWebhookRouter := publicWebHookRouter.PathPrefix("/terraform").Subrouter()
|
||||
terraformWebhookRouter.Use(TerraformInventoryAliasMiddleware)
|
||||
terraformWebhookRouter.Path("/{alias}").HandlerFunc(getTerraformState).Methods("GET")
|
||||
terraformWebhookRouter.Path("/{alias}").HandlerFunc(addTerraformState).Methods("POST")
|
||||
terraformWebhookRouter.Path("/{alias}").HandlerFunc(lockTerraformState).Methods("LOCK")
|
||||
terraformWebhookRouter.Path("/{alias}").HandlerFunc(unlockTerraformState).Methods("UNLOCK")
|
||||
|
||||
authenticatedWS := r.PathPrefix(webPath + "api").Subrouter()
|
||||
authenticatedWS.Use(JSONMiddleware, authenticationWithStore)
|
||||
|
@ -4,6 +4,12 @@ package api
|
||||
|
||||
import "net/http"
|
||||
|
||||
func TerraformInventoryAliasMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func getTerraformState(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user