Skip to content

Commit ee99155

Browse files
Updated routes for archival
1 parent 49d233a commit ee99155

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

api/routes/routes.go

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,31 @@ func RegisterRoutes(mux *http.ServeMux, sessionManager *session.Manager) {
134134

135135
/* for scheduling a transaction */
136136
mux.Handle("POST /transactions/schedule", http.HandlerFunc(
137-
middleware.LoggingMiddleware(
138-
middleware.AuthenticationMiddleware(sessionManager.IssueTransaction),
137+
middleware.CORSMiddleware(
138+
middleware.LoggingMiddleware(
139+
middleware.AuthenticationMiddleware(sessionManager.IssueTransaction),
140+
),
141+
allowedOrigin,
142+
allowedMethods,
143+
allowedHeaders,
139144
),
140145
))
141146

147+
/* handle OPTIONS preflight requests for /transactions/schedule */
148+
mux.HandleFunc("OPTIONS /transactions/schedule",
149+
middleware.CORSMiddleware(
150+
func(w http.ResponseWriter, r *http.Request) {
151+
/*
152+
This handler will never be called because CORSMiddleware handles OPTIONS
153+
but we need it for the route to be registered
154+
*/
155+
},
156+
allowedOrigin,
157+
allowedMethods,
158+
allowedHeaders,
159+
),
160+
)
161+
142162
/*
143163
for fetching list of users matching the query in the LDAP server
144164
supports URL params: q (Query)
@@ -203,7 +223,7 @@ func RegisterRoutes(mux *http.ServeMux, sessionManager *session.Manager) {
203223
/* ARCHIVE WILL BE MADE POST REQUEST -> Header based Authentication */
204224

205225
/* websocket connection for streaming user session data from PostgreSQL database (archived sessions) */
206-
mux.Handle("GET /users/archive/session", http.HandlerFunc(
226+
mux.Handle("POST /users/archive/session", http.HandlerFunc(
207227
middleware.CORSMiddleware(
208228
middleware.LoggingMiddleware(
209229
middleware.AuthenticationMiddleware(sessionManager.StreamUserArchiveSessions),
@@ -230,7 +250,7 @@ func RegisterRoutes(mux *http.ServeMux, sessionManager *session.Manager) {
230250
)
231251

232252
/* websocket connection for streaming user transactions data from PostgreSQL database (archived sessions) */
233-
mux.Handle("GET /users/archive/transactions/results", http.HandlerFunc(
253+
mux.Handle("POST /users/archive/transactions/results", http.HandlerFunc(
234254
middleware.CORSMiddleware(
235255
middleware.LoggingMiddleware(
236256
middleware.AuthenticationMiddleware(sessionManager.StreamUserArchiveResultsTransactions),
@@ -241,7 +261,7 @@ func RegisterRoutes(mux *http.ServeMux, sessionManager *session.Manager) {
241261
),
242262
))
243263

244-
/* handle OPTIONS preflight requests for /users/archive/transactions/results */
264+
/* handle OPTIONS preflight requests for /users/archive/transactions/results */
245265
mux.HandleFunc("OPTIONS /users/archive/transactions/results",
246266
middleware.CORSMiddleware(
247267
func(w http.ResponseWriter, r *http.Request) {
@@ -257,7 +277,7 @@ func RegisterRoutes(mux *http.ServeMux, sessionManager *session.Manager) {
257277
)
258278

259279
/* websocket connection for streaming user transactions data from PostgreSQL database (archived sessions) */
260-
mux.Handle("GET /users/archive/transactions/pending", http.HandlerFunc(
280+
mux.Handle("POST /users/archive/transactions/pending", http.HandlerFunc(
261281
middleware.CORSMiddleware(
262282
middleware.LoggingMiddleware(
263283
middleware.AuthenticationMiddleware(sessionManager.StreamUserArchivePendingTransactions),

0 commit comments

Comments
 (0)