1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package api
- import (
- "net/http"
- "github.com/go-chi/chi"
- "github.com/go-chi/render"
- "github.com/willie68/schematic-service-go/dao"
- )
- //SchematicsRoutes getting all routes for the config endpoint
- func SchematicsRoutes() *chi.Mux {
- router := chi.NewRouter()
- router.Post("/", PostSchematicEndpoint)
- router.Get("/", GetSchematicsEndpoint)
- router.Delete("/{schematicId}", DeleteSchematicEndpoint)
- router.Put("/{schematicId}", UpdateSchematicEndpoint)
- router.Get("/{schematicId}", GetSchematicHandler)
- router.Get("/{schematicId}/files/{fileId}", GetSchematicFileHandler)
- return router
- }
- // GetTenantHandler gets a tenant
- func GetSchematicHandler(response http.ResponseWriter, req *http.Request) {
- schematicID := chi.URLParam(req, "schematicId")
- schematic, err := dao.GetSchematic(schematicID)
- if err != nil {
- Msg(response, http.StatusBadRequest, err.Error())
- return
- }
- render.JSON(response, req, schematic)
- }
- // GetTenantHandler gets a tenant
- func GetSchematicFileHandler(response http.ResponseWriter, req *http.Request) {
- //schematicID := chi.URLParam(req, "schematicId")
- fileID := chi.URLParam(req, "fileId")
- err := dao.GetFile(fileID, response)
- if err != nil {
- Msg(response, http.StatusBadRequest, err.Error())
- return
- }
- //render.JSON(response, req, schematic)
- }
- // GetTenantsHandler gets all tenants
- func GetSchematicsEndpoint(response http.ResponseWriter, req *http.Request) {
- /*
- var tenants []dto.Tenant
- err := dao.Get().All("tenants", &tenants)
- if err != nil {
- Msg(response, http.StatusBadRequest, err.Error())
- return
- }
- */
- render.JSON(response, req, "tenants")
- }
- func PostSchematicEndpoint(response http.ResponseWriter, req *http.Request) {
- }
- func DeleteSchematicEndpoint(response http.ResponseWriter, req *http.Request) {
- /*
- schematicID := chi.URLParam(req, "schematicId")
- if err != nil {
- Msg(response, http.StatusBadRequest, err.Error())
- return
- }
- */
- render.JSON(response, req, "tenant")
- }
- func UpdateSchematicEndpoint(response http.ResponseWriter, req *http.Request) {
- /*
- schematicID := chi.URLParam(req, "schematicId")
- err := dao.Get().One("tenants", chi.URLParam(req, "schematicId"), &tenant)
- if err != nil {
- Msg(response, http.StatusBadRequest, err.Error())
- return
- }
- */
- render.JSON(response, req, "tenant")
- }
|