chore(tfstated): refactor backend code to a dedicated package
This commit is contained in:
parent
1dbb1b9ee7
commit
36e3d473f2
9 changed files with 60 additions and 36 deletions
22
pkg/backend/routes.go
Normal file
22
pkg/backend/routes.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package backend
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.adyxax.org/adyxax/tfstated/pkg/basic_auth"
|
||||
"git.adyxax.org/adyxax/tfstated/pkg/database"
|
||||
)
|
||||
|
||||
func addRoutes(
|
||||
mux *http.ServeMux,
|
||||
db *database.DB,
|
||||
) {
|
||||
mux.Handle("GET /healthz", handleHealthz())
|
||||
|
||||
basicAuth := basic_auth.Middleware(db)
|
||||
mux.Handle("DELETE /", basicAuth(handleDelete(db)))
|
||||
mux.Handle("GET /", basicAuth(handleGet(db)))
|
||||
mux.Handle("LOCK /", basicAuth(handleLock(db)))
|
||||
mux.Handle("POST /", basicAuth(handlePost(db)))
|
||||
mux.Handle("UNLOCK /", basicAuth(handleUnlock(db)))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue