forked from curt-labs/API
/
index.go
executable file
·538 lines (476 loc) · 23.9 KB
/
index.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
package main
import (
"flag"
"github.com/curt-labs/API/controllers/apiKeyType"
"github.com/curt-labs/API/controllers/applicationGuide"
"github.com/curt-labs/API/controllers/blog"
"github.com/curt-labs/API/controllers/brand"
"github.com/curt-labs/API/controllers/cache"
"github.com/curt-labs/API/controllers/cart"
"github.com/curt-labs/API/controllers/cartIntegration"
"github.com/curt-labs/API/controllers/category"
"github.com/curt-labs/API/controllers/contact"
"github.com/curt-labs/API/controllers/customer"
"github.com/curt-labs/API/controllers/dealers"
"github.com/curt-labs/API/controllers/faq"
"github.com/curt-labs/API/controllers/forum"
"github.com/curt-labs/API/controllers/geography"
"github.com/curt-labs/API/controllers/landingPages"
"github.com/curt-labs/API/controllers/middleware"
"github.com/curt-labs/API/controllers/news"
"github.com/curt-labs/API/controllers/part"
"github.com/curt-labs/API/controllers/salesrep"
"github.com/curt-labs/API/controllers/search"
"github.com/curt-labs/API/controllers/showcase"
"github.com/curt-labs/API/controllers/site"
"github.com/curt-labs/API/controllers/techSupport"
"github.com/curt-labs/API/controllers/testimonials"
"github.com/curt-labs/API/controllers/vehicle"
"github.com/curt-labs/API/controllers/videos"
"github.com/curt-labs/API/controllers/vinLookup"
"github.com/curt-labs/API/controllers/warranty"
"github.com/curt-labs/API/controllers/webProperty"
"github.com/curt-labs/API/helpers/encoding"
"github.com/go-martini/martini"
"github.com/martini-contrib/cors"
// "github.com/martini-contrib/gzip"
"log"
"net/http"
"time"
"github.com/martini-contrib/sessions"
)
var (
listenAddr = flag.String("http", ":8080", "http listen address")
)
/**
* All GET routes require either public or private api keys to be passed in.
*
* All POST routes require private api keys to be passed in.
*/
func main() {
flag.Parse()
m := martini.Classic()
// gorelic.InitNewrelicAgent("5fbc49f51bd658d47b4d5517f7a9cb407099c08c", "API", false)
// m.Use(gorelic.Handler)
// m.Use(gzip.All())
m.Use(middleware.Meddler())
m.Use(cors.Allow(&cors.Options{
AllowOrigins: []string{"*"},
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Content-Type", "Accept", "Access-Control-Allow-Origin", "Authorization"},
ExposeHeaders: []string{"Content-Type", "Accept", "Access-Control-Allow-Origin", "Authorization"},
AllowCredentials: false,
}))
store := sessions.NewCookieStore([]byte("api_secret_session"))
m.Use(sessions.Sessions("api_sessions", store))
m.Use(encoding.MapEncoder)
m.Group("/apiKeyTypes", func(r martini.Router) {
r.Get("", apiKeyType.GetApiKeyTypes)
})
m.Group("/applicationGuide", func(r martini.Router) {
r.Get("/website/:id", applicationGuide.GetApplicationGuidesByWebsite)
r.Get("/:id", applicationGuide.GetApplicationGuide)
r.Delete("/:id", applicationGuide.DeleteApplicationGuide)
r.Post("", applicationGuide.CreateApplicationGuide)
})
m.Group("/blogs", func(r martini.Router) {
r.Get("", blog_controller.GetAll) //sort on any field e.g. ?sort=Name&direction=descending
r.Get("/categories", blog_controller.GetAllCategories) //all categories; sort on any field e.g. ?sort=Name&direction=descending
r.Get("/category/:id", blog_controller.GetBlogCategory)
r.Get("/search", blog_controller.Search) //search field = value e.g. /blogs/search?key=8AEE0620-412E-47FC-900A-947820EA1C1D&slug=cyclo
r.Post("/categories", blog_controller.CreateBlogCategory)
r.Delete("/categories/:id", blog_controller.DeleteBlogCategory)
r.Get("/:id", blog_controller.GetBlog) //get blog by {id}
r.Put("/:id", blog_controller.UpdateBlog) //create {post_title ,slug ,post_text, createdDate, publishedDate, lastModified, userID, meta_title, meta_description, keywords, active} returns new id
r.Post("", blog_controller.CreateBlog) //update {post_title ,slug ,post_text, createdDate, publishedDate, lastModified, userID, meta_title, meta_description, keywords, active} required{id}
r.Delete("/:id", blog_controller.DeleteBlog) //{?id=id}
r.Delete("", blog_controller.DeleteBlog) //{id}
})
m.Group("/brands", func(r martini.Router) {
r.Get("", brand_ctlr.GetAllBrands)
r.Post("", brand_ctlr.CreateBrand)
r.Get("/:id", brand_ctlr.GetBrand)
r.Put("/:id", brand_ctlr.UpdateBrand)
r.Delete("/:id", brand_ctlr.DeleteBrand)
})
m.Group("/category", func(r martini.Router) {
r.Get("/:id/parts", category_ctlr.GetCategoryParts)
r.Get("/:id", category_ctlr.GetCategory)
r.Get("", category_ctlr.GetCategoryTree)
})
m.Group("/contact", func(r martini.Router) {
m.Group("/types", func(r martini.Router) {
r.Get("/receivers/:id", contact.GetReceiversByContactType)
r.Get("", contact.GetAllContactTypes)
r.Get("/:id", contact.GetContactType)
r.Post("", contact.AddContactType)
r.Put("/:id", contact.UpdateContactType)
r.Delete("/:id", contact.DeleteContactType)
})
m.Group("/receivers", func(r martini.Router) {
r.Get("", contact.GetAllContactReceivers)
r.Get("/:id", contact.GetContactReceiver)
r.Post("", contact.AddContactReceiver)
r.Put("/:id", contact.UpdateContactReceiver)
r.Delete("/:id", contact.DeleteContactReceiver)
})
// r.Post("/sendmail/:id", contact.SendEmail)
r.Get("", contact.GetAllContacts)
r.Get("/:id", contact.GetContact)
r.Post("/:contactTypeID", contact.AddDealerContact)
r.Put("/:id", contact.UpdateContact)
r.Delete("/:id", contact.DeleteContact)
})
m.Group("/shopify/customers", func(r martini.Router) {
// Customers - shop endpoints
r.Get("", cart_ctlr.GetCustomers)
r.Post("", cart_ctlr.AddCustomer)
r.Get("/search", cart_ctlr.SearchCustomer)
r.Get("/:id", cart_ctlr.GetCustomer)
r.Put("/:id", cart_ctlr.EditCustomer)
r.Delete("/:id", cart_ctlr.DeleteCustomer)
r.Get("/:id/orders", cart_ctlr.GetCustomerOrders)
// Addresses
r.Get("/:id/addresses", cart_ctlr.GetAddresses)
r.Get("/:id/addresses/:address", cart_ctlr.GetAddress)
r.Post("/:id/addresses", cart_ctlr.AddAddress)
r.Put("/:id/addresses/:address/default", cart_ctlr.SetDefaultAddress)
r.Put("/:id/addresses/:address", cart_ctlr.EditAddress)
r.Delete("/:id/addresses/:address", cart_ctlr.DeleteAddress)
})
m.Group("/shopify/order", func(r martini.Router) {
// Orders
r.Post("/order", cart_ctlr.CreateOrder)
})
m.Group("/shopify/account", func(r martini.Router) {
// Account - user endpoints
r.Get("", cart_ctlr.GetAccount)
r.Post("", cart_ctlr.AddAccount)
r.Put("", cart_ctlr.EditAccount)
r.Post("/login", cart_ctlr.AccountLogin)
// m.Group("/shopify/account/address", func(r martini.Router) {
// r.Get("", cart_ctlr.GetAccountAddresses)
// r.Post("", cart_ctlr.AddAccountAddress)
// r.Put("", cart_ctlr.EditAccountAddress)
// r.Delete("", cart_ctlr.DeleteAccountAddress)
// })
})
m.Group("/cartIntegration", func(r martini.Router) {
r.Get("/part/:part", cartIntegration.GetPartPricesByPartID)
r.Get("/part", cartIntegration.GetAllPartPrices)
r.Get("/count", cartIntegration.GetPricingCount)
r.Get("", cartIntegration.GetPricing)
r.Get("/:page/:count", cartIntegration.GetPricingPaged)
r.Post("/part", cartIntegration.CreatePrice)
r.Put("/part", cartIntegration.UpdatePrice)
r.Get("/priceTypes", cartIntegration.GetAllPriceTypes)
r.Post("/resetToMap", cartIntegration.ResetAllToMap)
r.Post("/global/:type/:percentage", cartIntegration.Global)
r.Post("/upload", cartIntegration.Upload)
r.Post("/download", cartIntegration.Download)
})
m.Group("/cache", func(r martini.Router) { // different endpoint because partial matching matches this to another excused route
r.Get("/key", cache.GetByKey)
r.Get("/keys", cache.GetKeys)
r.Delete("/keys", cache.DeleteKey)
})
m.Group("/cust", func(r martini.Router) { // different endpoint because partial matching matches this to another excused route
r.Post("/user/changePassword", customer_ctlr.ChangePassword)
})
m.Group("/cache", func(r martini.Router) { // different endpoint because partial matching matches this to another excused route
r.Get("/key", cache.GetByKey)
r.Get("/keys", cache.GetKeys)
r.Delete("/keys", cache.DeleteKey)
})
m.Group("/customer", func(r martini.Router) {
r.Get("", customer_ctlr.GetCustomer)
r.Post("", customer_ctlr.GetCustomer)
r.Post("/auth", customer_ctlr.AuthenticateUser)
r.Get("/auth", customer_ctlr.KeyedUserAuthentication)
r.Post("/user/changePassword", customer_ctlr.ChangePassword)
r.Post("/user", customer_ctlr.GetUser)
r.Post("/user/register", customer_ctlr.RegisterUser)
r.Post("/user/resetPassword", customer_ctlr.ResetPassword)
r.Delete("/deleteKey", customer_ctlr.DeleteUserApiKey)
r.Post("/generateKey/user/:id/key/:type", customer_ctlr.GenerateApiKey)
r.Get("/user/:id", customer_ctlr.GetUserById)
r.Post("/user/:id", customer_ctlr.UpdateCustomerUser)
r.Delete("/user/:id", customer_ctlr.DeleteCustomerUser)
r.Any("/users", customer_ctlr.GetUsers)
r.Delete("/allUsersByCustomerID/:id", customer_ctlr.DeleteCustomerUsersByCustomerID) //Takes CustomerID (UUID)---danger!
r.Put("/location/json", customer_ctlr.SaveLocationJson)
r.Put("/location/json/:id", customer_ctlr.SaveLocationJson)
r.Post("/location", customer_ctlr.SaveLocation)
r.Get("/location/:id", customer_ctlr.GetLocation)
r.Put("/location/:id", customer_ctlr.SaveLocation)
r.Delete("/location/:id", customer_ctlr.DeleteLocation)
r.Get("/locations", customer_ctlr.GetLocations)
r.Post("/locations", customer_ctlr.GetLocations)
r.Get("/price/:id", customer_ctlr.GetCustomerPrice) //{part id}
r.Get("/cartRef/:id", customer_ctlr.GetCustomerCartReference) //{part id}
// Customer CMS endpoints
// All Customer Contents
r.Get("/cms", customer_ctlr.GetAllContent)
// Content Types
r.Get("/cms/content_types", customer_ctlr.GetAllContentTypes)
// Customer Part Content
r.Get("/cms/part", customer_ctlr.AllPartContent)
r.Get("/cms/part/:id", customer_ctlr.UniquePartContent)
r.Put("/cms/part/:id", customer_ctlr.UpdatePartContent) //partId
r.Post("/cms/part/:id", customer_ctlr.CreatePartContent)
r.Delete("/cms/part/:id", customer_ctlr.DeletePartContent)
// Customer Category Content
r.Get("/cms/category", customer_ctlr.AllCategoryContent)
r.Get("/cms/category/:id", customer_ctlr.UniqueCategoryContent)
r.Post("/cms/category/:id", customer_ctlr.UpdateCategoryContent) //categoryId
r.Delete("/cms/category/:id", customer_ctlr.DeleteCategoryContent)
// Customer Content By Content Id
r.Get("/cms/:id", customer_ctlr.GetContentById)
r.Get("/cms/:id/revisions", customer_ctlr.GetContentRevisionsById)
//Customer prices
r.Get("/prices/part/:id", customer_ctlr.GetPricesByPart) //{id}; id refers to partId
r.Post("/prices/sale", customer_ctlr.GetSales) //{start}{end}{id} -all required params; id refers to customerId
r.Get("/prices/:id", customer_ctlr.GetPrice) //{id}; id refers to {id} refers to customerPriceId
r.Get("/prices", customer_ctlr.GetAllPrices) //returns all {sort=field&direction=dir}
r.Put("/prices/:id", customer_ctlr.CreateUpdatePrice) //updates when an id is present; otherwise, creates; {id} refers to customerPriceId
r.Post("/prices", customer_ctlr.CreateUpdatePrice) //updates when an id is present; otherwise, creates; {id} refers to customerPriceId
r.Delete("/prices/:id", customer_ctlr.DeletePrice) //{id} refers to customerPriceId
r.Get("/pricesByCustomer/:id", customer_ctlr.GetPriceByCustomer) //{id} refers to customerId; returns CustomerPrices
r.Post("/:id", customer_ctlr.SaveCustomer)
r.Delete("/:id", customer_ctlr.DeleteCustomer)
r.Put("", customer_ctlr.SaveCustomer)
})
m.Group("/dealers", func(r martini.Router) {
r.Get("/business/classes", dealers_ctlr.GetAllBusinessClasses)
r.Get("/etailer", dealers_ctlr.GetEtailers)
r.Get("/local", dealers_ctlr.GetLocalDealers)
r.Get("/local/regions", dealers_ctlr.GetLocalRegions)
r.Get("/local/tiers", dealers_ctlr.GetLocalDealerTiers)
r.Get("/local/types", dealers_ctlr.GetLocalDealerTypes)
r.Get("/etailer/platinum", dealers_ctlr.PlatinumEtailers)
r.Get("/location/:id", dealers_ctlr.GetLocationById)
r.Get("/search/:search", dealers_ctlr.SearchLocations)
r.Get("/search/type/:search", dealers_ctlr.SearchLocationsByType)
r.Get("/search/geo/:latitude/:longitude", dealers_ctlr.SearchLocationsByLatLng)
})
m.Group("/faqs", func(r martini.Router) {
r.Get("", faq_controller.GetAll) //get all faqs; takes optional sort param {sort=true} to sort by question
r.Get("/search", faq_controller.Search) //takes {question, answer, page, results} - all parameters are optional
r.Get("/(:id)", faq_controller.Get) //get by id {id}
r.Post("", faq_controller.Create) //takes {question, answer}; returns object with new ID
r.Put("/(:id)", faq_controller.Update) //{id, question and/or answer}
r.Delete("/(:id)", faq_controller.Delete) //{id}
r.Delete("", faq_controller.Delete) //{?id=id}
})
m.Group("/forum", func(r martini.Router) {
//groups
r.Get("/groups", forum_ctlr.GetAllGroups)
r.Get("/groups/:id", forum_ctlr.GetGroup)
r.Post("/groups", forum_ctlr.AddGroup)
r.Put("/groups/:id", forum_ctlr.UpdateGroup)
r.Delete("/groups/:id", forum_ctlr.DeleteGroup)
//topics
r.Get("/topics", forum_ctlr.GetAllTopics)
r.Get("/topics/:id", forum_ctlr.GetTopic)
r.Post("/topics", forum_ctlr.AddTopic)
r.Put("/topics/:id", forum_ctlr.UpdateTopic)
r.Delete("/topics/:id", forum_ctlr.DeleteTopic)
//threads
r.Get("/threads", forum_ctlr.GetAllThreads)
r.Get("/threads/:id", forum_ctlr.GetThread)
r.Delete("/threads/:id", forum_ctlr.DeleteThread)
//posts
r.Get("/posts", forum_ctlr.GetAllPosts)
r.Get("/posts/:id", forum_ctlr.GetPost)
r.Post("/posts", forum_ctlr.AddPost)
r.Put("/posts/:id", forum_ctlr.UpdatePost)
r.Delete("/posts/:id", forum_ctlr.DeletePost)
})
m.Group("/geography", func(r martini.Router) {
r.Get("/states", geography.GetAllStates)
r.Get("/countries", geography.GetAllCountries)
r.Get("/countrystates", geography.GetAllCountriesAndStates)
})
m.Group("/news", func(r martini.Router) {
r.Get("", news_controller.GetAll) //get all news; takes optional sort param {sort=title||lead||content||startDate||endDate||active||slug} to sort by question
r.Get("/titles", news_controller.GetTitles) //get titles!{page, results} - all parameters are optional
r.Get("/leads", news_controller.GetLeads) //get leads!{page, results} - all parameters are optional
r.Get("/search", news_controller.Search) //takes {title, lead, content, publishStart, publishEnd, active, slug, page, results, page, results} - all parameters are optional
r.Get("/:id", news_controller.Get) //get by id {id}
r.Post("", news_controller.Create) //takes {question, answer}; returns object with new ID
r.Post("/:id", news_controller.Update) //{id, question and/or answer}
r.Delete("/:id", news_controller.Delete) //{id}
r.Delete("", news_controller.Delete) //{id}
})
m.Group("/part", func(r martini.Router) {
r.Get("/featured", part_ctlr.Featured)
r.Get("/latest", part_ctlr.Latest)
r.Get("/:part/vehicles", part_ctlr.Vehicles)
r.Get("/:part/attributes", part_ctlr.Attributes)
r.Get("/:part/reviews", part_ctlr.ActiveApprovedReviews)
r.Get("/:part/categories", part_ctlr.Categories)
r.Get("/:part/content", part_ctlr.GetContent)
r.Get("/:part/images", part_ctlr.Images)
r.Get("/:part((.*?)\\.(PDF|pdf)$)", part_ctlr.InstallSheet)
r.Get("/:part/packages", part_ctlr.Packaging)
r.Get("/:part/pricing", part_ctlr.Prices)
r.Get("/:part/related", part_ctlr.GetRelated)
r.Get("/:part/videos", part_ctlr.Videos)
r.Get("/:part/:year/:make/:model", part_ctlr.GetWithVehicle)
r.Get("/:part/:year/:make/:model/:submodel", part_ctlr.GetWithVehicle)
r.Get("/:part/:year/:make/:model/:submodel/:config(.+)", part_ctlr.GetWithVehicle)
r.Get("/id/:part", part_ctlr.Get)
r.Get("/identifiers", part_ctlr.Identifiers)
r.Get("/:part", part_ctlr.PartNumber)
r.Get("", part_ctlr.All)
})
m.Group("/salesrep", func(r martini.Router) {
r.Get("", salesrep.GetAllSalesReps)
r.Post("", salesrep.AddSalesRep)
r.Get("/:id", salesrep.GetSalesRep)
r.Put("/:id", salesrep.UpdateSalesRep)
r.Delete("/:id", salesrep.DeleteSalesRep)
})
m.Get("/search/:term", search_ctlr.Search)
m.Group("/site", func(r martini.Router) {
m.Group("/menu", func(r martini.Router) {
r.Get("/all", site.GetAllMenus)
r.Get("/:id", site.GetMenu) //may pass id (int) or name(string)
r.Get("/contents/:id", site.GetMenuWithContents) //may pass id (int) or name(string)
r.Post("", site.SaveMenu)
r.Put("/:id", site.SaveMenu)
r.Delete("/:id", site.DeleteMenu)
})
m.Group("/content", func(r martini.Router) {
r.Get("/all", site.GetAllContents)
r.Get("/:id", site.GetContent) //may pass id (int) or slug(string)
r.Get("/:id/revisions", site.GetContentRevisions)
r.Post("", site.SaveContent)
r.Put("/:id", site.SaveContent)
r.Delete("/:id", site.DeleteContent)
})
r.Get("/details/:id", site.GetSiteDetails)
r.Post("", site.SaveSite)
r.Put("/:id", site.SaveSite)
r.Delete("/:id", site.DeleteSite)
})
m.Group("/lp", func(r martini.Router) {
r.Get("/:id", landingPage.Get)
})
m.Group("/showcase", func(r martini.Router) {
r.Get("", showcase.GetAllShowcases)
r.Get("/:id", showcase.GetShowcase)
r.Post("", showcase.Save)
// r.Put("/:id", showcase.Save)
// r.Delete("/:id", showcase.Delete)
})
m.Group("/techSupport", func(r martini.Router) {
r.Get("/all", techSupport.GetAllTechSupport)
r.Get("/contact/:id", techSupport.GetTechSupportByContact)
r.Get("/:id", techSupport.GetTechSupport)
r.Post("/:contactReceiverTypeID/:sendEmail", techSupport.CreateTechSupport) //contactType determines who receives the email/sendEmail is a bool indicating if email should be sent
r.Delete("/:id", techSupport.DeleteTechSupport)
})
m.Group("/testimonials", func(r martini.Router) {
r.Get("", testimonials.GetAllTestimonials)
r.Get("/:id", testimonials.GetTestimonial)
r.Post("", testimonials.Save)
r.Put("/:id", testimonials.Save)
r.Delete("/:id", testimonials.Delete)
})
m.Group("/warranty", func(r martini.Router) {
r.Get("/all", warranty.GetAllWarranties)
r.Get("/contact/:id", warranty.GetWarrantyByContact)
r.Get("/:id", warranty.GetWarranty)
r.Post("/:contactReceiverTypeID/:sendEmail", warranty.CreateWarranty) //contactType determines who receives the email/sendEmail is a bool indicating if email should be sent
r.Delete("/:id", warranty.DeleteWarranty)
})
m.Group("/webProperties", func(r martini.Router) {
r.Post("/json/type", webProperty_controller.CreateUpdateWebPropertyType)
r.Post("/json/type/:id", webProperty_controller.CreateUpdateWebPropertyType)
r.Post("/json/requirement", webProperty_controller.CreateUpdateWebPropertyRequirement)
r.Post("/json/requirement/:id", webProperty_controller.CreateUpdateWebPropertyRequirement)
r.Post("/json/note", webProperty_controller.CreateUpdateWebPropertyNote)
r.Post("/json/note/:id", webProperty_controller.CreateUpdateWebPropertyNote)
r.Post("/json/:id", webProperty_controller.CreateUpdateWebProperty)
r.Put("/json", webProperty_controller.CreateUpdateWebProperty)
r.Post("/note/:id", webProperty_controller.CreateUpdateWebPropertyNote) //updates when an id is present; otherwise, creates
r.Put("/note", webProperty_controller.CreateUpdateWebPropertyNote) //updates when an id is present; otherwise, creates
r.Delete("/note/:id", webProperty_controller.DeleteWebPropertyNote) //{id}
r.Get("/note/:id", webProperty_controller.GetWebPropertyNote) //{id}
r.Post("/type/:id", webProperty_controller.CreateUpdateWebPropertyType) //updates when an id is present; otherwise, creates
r.Put("/type", webProperty_controller.CreateUpdateWebPropertyType) //updates when an id is present; otherwise, creates
r.Delete("/type/:id", webProperty_controller.DeleteWebPropertyType) //{id}
r.Get("/type/:id", webProperty_controller.GetWebPropertyType) //{id}
r.Post("/requirement/:id", webProperty_controller.CreateUpdateWebPropertyRequirement) //updates when an id is present; otherwise, creates
r.Put("/requirement", webProperty_controller.CreateUpdateWebPropertyRequirement) //updates when an id is present; otherwise, creates
r.Delete("/requirement/:id", webProperty_controller.DeleteWebPropertyRequirement) //{id}
r.Get("/requirement/:id", webProperty_controller.GetWebPropertyRequirement) //{id}
r.Get("/search", webProperty_controller.Search)
r.Get("/type", webProperty_controller.GetAllTypes)
r.Get("/note", webProperty_controller.GetAllNotes)
r.Get("/requirement", webProperty_controller.GetAllRequirements)
r.Get("/customer", webProperty_controller.GetByPrivateKey)
r.Get("", webProperty_controller.GetAll)
r.Get("/:id", webProperty_controller.Get) //?id=id
r.Delete("/:id", webProperty_controller.DeleteWebProperty) //{id}
r.Post("/:id", webProperty_controller.CreateUpdateWebProperty) //
r.Put("", webProperty_controller.CreateUpdateWebProperty) //can create notes(text) and requirements (requirement, by requirement=requirementID) while creating a property
})
// ARIES Year/Make/Model/Style
m.Post("/vehicle", vehicle.Query)
m.Post("/findVehicle", vehicle.GetVehicle)
m.Post("/vehicle/inquire", vehicle.Inquire)
m.Get("/vehicle/mongo/cols", vehicle.Collections)
m.Post("/vehicle/mongo/apps", vehicle.ByCategory)
m.Post("/vehicle/mongo/allCollections/category", vehicle.AllCollectionsLookupCategory)
m.Post("/vehicle/mongo/allCollections", vehicle.AllCollectionsLookup)
m.Post("/vehicle/mongo", vehicle.Lookup)
m.Post("/vehicle/mongo/import", vehicle.ImportCsv)
m.Get("/vehicle/mongo/all/:collection", vehicle.GetAllCollectionApplications)
m.Put("/vehicle/mongo/:collection", vehicle.UpdateApplication)
m.Delete("/vehicle/mongo/:collection", vehicle.DeleteApplication)
m.Post("/vehicle/mongo/:collection", vehicle.CreateApplication)
// CURT Year/Make/Model/Style
m.Post("/vehicle/curt", vehicle.CurtLookup)
m.Get("/vehicle/curt/report", vehicle.CURTApps)
m.Group("/videos", func(r martini.Router) {
r.Get("/distinct", videos_ctlr.DistinctVideos) //old "videos" table - curtmfg?
r.Get("/channel/type", videos_ctlr.GetAllChannelTypes)
r.Get("/channel/type/:id", videos_ctlr.GetChannelType)
r.Get("/channel", videos_ctlr.GetAllChannels)
r.Get("/channels", videos_ctlr.GetAllChannels)
r.Get("/channel/:id", videos_ctlr.GetChannel)
r.Get("/cdn/type", videos_ctlr.GetAllCdnTypes)
r.Get("/cdn/type/:id", videos_ctlr.GetCdnType)
r.Get("/cdn", videos_ctlr.GetAllCdns)
r.Get("/cdn/:id", videos_ctlr.GetCdn)
r.Get("/type", videos_ctlr.GetAllVideoTypes)
r.Get("/type/:id", videos_ctlr.GetVideoType)
r.Get("", videos_ctlr.GetAllVideos)
r.Get("/details/:id", videos_ctlr.GetVideoDetails)
r.Get("/:id", videos_ctlr.Get)
})
m.Group("/vin", func(r martini.Router) {
//option 1 - two calls - ultimately returns parts
r.Get("/configs/:vin", vinLookup.GetConfigs) //returns vehicles - user must call vin/vehicle with vehicleID to get parts
r.Get("/vehicleID/:vehicleID", vinLookup.GetPartsFromVehicleID) //returns an array of parts
//option 2 - one call - returns vehicles with parts
r.Get("/:vin", vinLookup.GetParts) //returns vehicles + configs with associates parts -or- an array of parts if only one vehicle config matches
})
m.Get("/status", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
w.Write([]byte("running"))
})
m.Get("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "http://labs.curtmfg.com/", http.StatusFound)
})
srv := &http.Server{
Addr: *listenAddr,
Handler: m,
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
}
log.Printf("Starting server on 127.0.0.1%s\n", *listenAddr)
log.Fatal(srv.ListenAndServe())
}