feat(tf): add middleware for state

This commit is contained in:
Denis Gukov 2024-12-16 02:30:06 +05:00
parent f151ee7b89
commit 80d5b4a276
No known key found for this signature in database
GPG Key ID: 044381366A5D4731
2 changed files with 12 additions and 4 deletions

View File

@ -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)

View File

@ -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)
}