@@ -16,6 +16,7 @@ import (
16
16
"strings"
17
17
"time"
18
18
19
+ gz "github.com/NYTimes/gziphandler"
19
20
"github.com/bradfitz/gomemcache/memcache"
20
21
gsm "github.com/bradleypeabody/gorilla-sessions-memcache"
21
22
"github.com/gwenn/gosqlite"
@@ -3275,138 +3276,138 @@ func main() {
3275
3276
go com .SendEmails ()
3276
3277
3277
3278
// Our pages
3278
- http .HandleFunc ("/" , logReq (mainHandler ))
3279
- http .HandleFunc ("/about" , logReq (aboutPage ))
3280
- http .HandleFunc ("/branches/" , logReq (branchesPage ))
3281
- http .HandleFunc ("/commits/" , logReq (commitsPage ))
3282
- http .HandleFunc ("/compare/" , logReq (comparePage ))
3283
- http .HandleFunc ("/confirmdelete/" , logReq (confirmDeletePage ))
3284
- http .HandleFunc ("/contributors/" , logReq (contributorsPage ))
3285
- http .HandleFunc ("/createbranch/" , logReq (createBranchPage ))
3286
- http .HandleFunc ("/creatediscuss/" , logReq (createDiscussionPage ))
3287
- http .HandleFunc ("/createtag/" , logReq (createTagPage ))
3288
- http .HandleFunc ("/discuss/" , logReq (discussPage ))
3289
- http .HandleFunc ("/forks/" , logReq (forksPage ))
3290
- http .HandleFunc ("/logout" , logReq (logoutHandler ))
3291
- http .HandleFunc ("/merge/" , logReq (mergePage ))
3292
- http .HandleFunc ("/pref" , logReq (prefHandler ))
3293
- http .HandleFunc ("/register" , logReq (createUserHandler ))
3294
- http .HandleFunc ("/releases/" , logReq (releasesPage ))
3295
- http .HandleFunc ("/selectusername" , logReq (selectUserNamePage ))
3296
- http .HandleFunc ("/settings/" , logReq (settingsPage ))
3297
- http .HandleFunc ("/stars/" , logReq (starsPage ))
3298
- http .HandleFunc ("/tags/" , logReq (tagsPage ))
3299
- http .HandleFunc ("/updates/" , logReq (updatesPage ))
3300
- http .HandleFunc ("/upload/" , logReq (uploadPage ))
3301
- http .HandleFunc ("/watchers/" , logReq (watchersPage ))
3302
- http .HandleFunc ("/x/branchnames" , logReq (branchNamesHandler ))
3303
- http .HandleFunc ("/x/callback" , logReq (auth0CallbackHandler ))
3304
- http .HandleFunc ("/x/checkname" , logReq (checkNameHandler ))
3305
- http .HandleFunc ("/x/createbranch" , logReq (createBranchHandler ))
3306
- http .HandleFunc ("/x/createcomment/" , logReq (createCommentHandler ))
3307
- http .HandleFunc ("/x/creatediscuss" , logReq (createDiscussHandler ))
3308
- http .HandleFunc ("/x/createmerge/" , logReq (createMergeHandler ))
3309
- http .HandleFunc ("/x/createtag" , logReq (createTagHandler ))
3310
- http .HandleFunc ("/x/deletebranch/" , logReq (deleteBranchHandler ))
3311
- http .HandleFunc ("/x/deletecomment/" , logReq (deleteCommentHandler ))
3312
- http .HandleFunc ("/x/deletecommit/" , logReq (deleteCommitHandler ))
3313
- http .HandleFunc ("/x/deletedatabase/" , logReq (deleteDatabaseHandler ))
3314
- http .HandleFunc ("/x/deleterelease/" , logReq (deleteReleaseHandler ))
3315
- http .HandleFunc ("/x/deletetag/" , logReq (deleteTagHandler ))
3316
- http .HandleFunc ("/x/diffcommitlist/" , logReq (diffCommitListHandler ))
3317
- http .HandleFunc ("/x/download/" , logReq (downloadHandler ))
3318
- http .HandleFunc ("/x/downloadcsv/" , logReq (downloadCSVHandler ))
3319
- http .HandleFunc ("/x/downloadredashjson/" , logReq (downloadRedashJSONHandler ))
3320
- http .HandleFunc ("/x/forkdb/" , logReq (forkDBHandler ))
3321
- http .HandleFunc ("/x/gencert" , logReq (generateCertHandler ))
3322
- http .HandleFunc ("/x/markdownpreview/" , logReq (markdownPreview ))
3323
- http .HandleFunc ("/x/mergerequest/" , logReq (mergeRequestHandler ))
3324
- http .HandleFunc ("/x/savesettings" , logReq (saveSettingsHandler ))
3325
- http .HandleFunc ("/x/setdefaultbranch/" , logReq (setDefaultBranchHandler ))
3326
- http .HandleFunc ("/x/star/" , logReq (starToggleHandler ))
3327
- http .HandleFunc ("/x/table/" , logReq (tableViewHandler ))
3328
- http .HandleFunc ("/x/tablenames/" , logReq (tableNamesHandler ))
3329
- http .HandleFunc ("/x/updatebranch/" , logReq (updateBranchHandler ))
3330
- http .HandleFunc ("/x/updatecomment/" , logReq (updateCommentHandler ))
3331
- http .HandleFunc ("/x/updatediscuss/" , logReq (updateDiscussHandler ))
3332
- http .HandleFunc ("/x/updaterelease/" , logReq (updateReleaseHandler ))
3333
- http .HandleFunc ("/x/updatetag/" , logReq (updateTagHandler ))
3334
- http .HandleFunc ("/x/uploaddata/" , logReq (uploadDataHandler ))
3335
- http .HandleFunc ("/x/watch/" , logReq (watchToggleHandler ))
3279
+ http .Handle ("/" , gz . GzipHandler ( logReq (mainHandler ) ))
3280
+ http .Handle ("/about" , gz . GzipHandler ( logReq (aboutPage ) ))
3281
+ http .Handle ("/branches/" , gz . GzipHandler ( logReq (branchesPage ) ))
3282
+ http .Handle ("/commits/" , gz . GzipHandler ( logReq (commitsPage ) ))
3283
+ http .Handle ("/compare/" , gz . GzipHandler ( logReq (comparePage ) ))
3284
+ http .Handle ("/confirmdelete/" , gz . GzipHandler ( logReq (confirmDeletePage ) ))
3285
+ http .Handle ("/contributors/" , gz . GzipHandler ( logReq (contributorsPage ) ))
3286
+ http .Handle ("/createbranch/" , gz . GzipHandler ( logReq (createBranchPage ) ))
3287
+ http .Handle ("/creatediscuss/" , gz . GzipHandler ( logReq (createDiscussionPage ) ))
3288
+ http .Handle ("/createtag/" , gz . GzipHandler ( logReq (createTagPage ) ))
3289
+ http .Handle ("/discuss/" , gz . GzipHandler ( logReq (discussPage ) ))
3290
+ http .Handle ("/forks/" , gz . GzipHandler ( logReq (forksPage ) ))
3291
+ http .Handle ("/logout" , gz . GzipHandler ( logReq (logoutHandler ) ))
3292
+ http .Handle ("/merge/" , gz . GzipHandler ( logReq (mergePage ) ))
3293
+ http .Handle ("/pref" , gz . GzipHandler ( logReq (prefHandler ) ))
3294
+ http .Handle ("/register" , gz . GzipHandler ( logReq (createUserHandler ) ))
3295
+ http .Handle ("/releases/" , gz . GzipHandler ( logReq (releasesPage ) ))
3296
+ http .Handle ("/selectusername" , gz . GzipHandler ( logReq (selectUserNamePage ) ))
3297
+ http .Handle ("/settings/" , gz . GzipHandler ( logReq (settingsPage ) ))
3298
+ http .Handle ("/stars/" , gz . GzipHandler ( logReq (starsPage ) ))
3299
+ http .Handle ("/tags/" , gz . GzipHandler ( logReq (tagsPage ) ))
3300
+ http .Handle ("/updates/" , gz . GzipHandler ( logReq (updatesPage ) ))
3301
+ http .Handle ("/upload/" , gz . GzipHandler ( logReq (uploadPage ) ))
3302
+ http .Handle ("/watchers/" , gz . GzipHandler ( logReq (watchersPage ) ))
3303
+ http .Handle ("/x/branchnames" , gz . GzipHandler ( logReq (branchNamesHandler ) ))
3304
+ http .Handle ("/x/callback" , gz . GzipHandler ( logReq (auth0CallbackHandler ) ))
3305
+ http .Handle ("/x/checkname" , gz . GzipHandler ( logReq (checkNameHandler ) ))
3306
+ http .Handle ("/x/createbranch" , gz . GzipHandler ( logReq (createBranchHandler ) ))
3307
+ http .Handle ("/x/createcomment/" , gz . GzipHandler ( logReq (createCommentHandler ) ))
3308
+ http .Handle ("/x/creatediscuss" , gz . GzipHandler ( logReq (createDiscussHandler ) ))
3309
+ http .Handle ("/x/createmerge/" , gz . GzipHandler ( logReq (createMergeHandler ) ))
3310
+ http .Handle ("/x/createtag" , gz . GzipHandler ( logReq (createTagHandler ) ))
3311
+ http .Handle ("/x/deletebranch/" , gz . GzipHandler ( logReq (deleteBranchHandler ) ))
3312
+ http .Handle ("/x/deletecomment/" , gz . GzipHandler ( logReq (deleteCommentHandler ) ))
3313
+ http .Handle ("/x/deletecommit/" , gz . GzipHandler ( logReq (deleteCommitHandler ) ))
3314
+ http .Handle ("/x/deletedatabase/" , gz . GzipHandler ( logReq (deleteDatabaseHandler ) ))
3315
+ http .Handle ("/x/deleterelease/" , gz . GzipHandler ( logReq (deleteReleaseHandler ) ))
3316
+ http .Handle ("/x/deletetag/" , gz . GzipHandler ( logReq (deleteTagHandler ) ))
3317
+ http .Handle ("/x/diffcommitlist/" , gz . GzipHandler ( logReq (diffCommitListHandler ) ))
3318
+ http .Handle ("/x/download/" , gz . GzipHandler ( logReq (downloadHandler ) ))
3319
+ http .Handle ("/x/downloadcsv/" , gz . GzipHandler ( logReq (downloadCSVHandler ) ))
3320
+ http .Handle ("/x/downloadredashjson/" , gz . GzipHandler ( logReq (downloadRedashJSONHandler ) ))
3321
+ http .Handle ("/x/forkdb/" , gz . GzipHandler ( logReq (forkDBHandler ) ))
3322
+ http .Handle ("/x/gencert" , gz . GzipHandler ( logReq (generateCertHandler ) ))
3323
+ http .Handle ("/x/markdownpreview/" , gz . GzipHandler ( logReq (markdownPreview ) ))
3324
+ http .Handle ("/x/mergerequest/" , gz . GzipHandler ( logReq (mergeRequestHandler ) ))
3325
+ http .Handle ("/x/savesettings" , gz . GzipHandler ( logReq (saveSettingsHandler ) ))
3326
+ http .Handle ("/x/setdefaultbranch/" , gz . GzipHandler ( logReq (setDefaultBranchHandler ) ))
3327
+ http .Handle ("/x/star/" , gz . GzipHandler ( logReq (starToggleHandler ) ))
3328
+ http .Handle ("/x/table/" , gz . GzipHandler ( logReq (tableViewHandler ) ))
3329
+ http .Handle ("/x/tablenames/" , gz . GzipHandler ( logReq (tableNamesHandler ) ))
3330
+ http .Handle ("/x/updatebranch/" , gz . GzipHandler ( logReq (updateBranchHandler ) ))
3331
+ http .Handle ("/x/updatecomment/" , gz . GzipHandler ( logReq (updateCommentHandler ) ))
3332
+ http .Handle ("/x/updatediscuss/" , gz . GzipHandler ( logReq (updateDiscussHandler ) ))
3333
+ http .Handle ("/x/updaterelease/" , gz . GzipHandler ( logReq (updateReleaseHandler ) ))
3334
+ http .Handle ("/x/updatetag/" , gz . GzipHandler ( logReq (updateTagHandler ) ))
3335
+ http .Handle ("/x/uploaddata/" , gz . GzipHandler ( logReq (uploadDataHandler ) ))
3336
+ http .Handle ("/x/watch/" , gz . GzipHandler ( logReq (watchToggleHandler ) ))
3336
3337
3337
3338
// CSS
3338
- http .HandleFunc ("/css/bootstrap-3.3.7.min.css" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3339
+ http .Handle ("/css/bootstrap-3.3.7.min.css" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3339
3340
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "css" , "bootstrap-3.3.7.min.css" ))
3340
- }))
3341
- http .HandleFunc ("/css/bootstrap.min.css.map" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3341
+ })))
3342
+ http .Handle ("/css/bootstrap.min.css.map" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3342
3343
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "css" , "bootstrap-3.3.7.min.css.map" ))
3343
- }))
3344
- http .HandleFunc ("/css/font-awesome-4.7.0.min.css" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3344
+ })))
3345
+ http .Handle ("/css/font-awesome-4.7.0.min.css" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3345
3346
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "css" , "font-awesome-4.7.0.min.css" ))
3346
- }))
3347
- http .HandleFunc ("/css/local.css" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3347
+ })))
3348
+ http .Handle ("/css/local.css" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3348
3349
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "css" , "local.css" ))
3349
- }))
3350
+ })))
3350
3351
3351
3352
// Fonts
3352
- http .HandleFunc ("/css/FontAwesome.otf" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3353
+ http .Handle ("/css/FontAwesome.otf" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3353
3354
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "fonts" , "FontAwesome-4.7.0.otf" ))
3354
- }))
3355
- http .HandleFunc ("/css/fontawesome-webfont.eot" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3355
+ })))
3356
+ http .Handle ("/css/fontawesome-webfont.eot" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3356
3357
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "fonts" , "fontawesome-webfont-4.7.0.eot" ))
3357
- }))
3358
- http .HandleFunc ("/css/fontawesome-webfont.svg" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3358
+ })))
3359
+ http .Handle ("/css/fontawesome-webfont.svg" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3359
3360
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "fonts" , "fontawesome-webfont-4.7.0.svg" ))
3360
- }))
3361
- http .HandleFunc ("/css/fontawesome-webfont.ttf" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3361
+ })))
3362
+ http .Handle ("/css/fontawesome-webfont.ttf" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3362
3363
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "fonts" , "fontawesome-webfont-4.7.0.ttf" ))
3363
- }))
3364
- http .HandleFunc ("/css/fontawesome-webfont.woff" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3364
+ })))
3365
+ http .Handle ("/css/fontawesome-webfont.woff" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3365
3366
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "fonts" , "fontawesome-webfont-4.7.0.woff" ))
3366
- }))
3367
- http .HandleFunc ("/css/fontawesome-webfont.woff2" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3367
+ })))
3368
+ http .Handle ("/css/fontawesome-webfont.woff2" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3368
3369
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "fonts" , "fontawesome-webfont-4.7.0.woff2" ))
3369
- }))
3370
+ })))
3370
3371
3371
3372
// Javascript
3372
- http .HandleFunc ("/js/angular-1.7.8.min.js" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3373
+ http .Handle ("/js/angular-1.7.8.min.js" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3373
3374
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "js" , "angular-1.7.8.min.js" ))
3374
- }))
3375
- http .HandleFunc ("/js/angular.min.js.map" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3375
+ })))
3376
+ http .Handle ("/js/angular.min.js.map" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3376
3377
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "js" , "angular-1.7.8.min.js.map" ))
3377
- }))
3378
- http .HandleFunc ("/js/angular-sanitize-1.7.8.min.js" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3378
+ })))
3379
+ http .Handle ("/js/angular-sanitize-1.7.8.min.js" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3379
3380
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "js" , "angular-sanitize-1.7.8.min.js" ))
3380
- }))
3381
- http .HandleFunc ("/js/angular-sanitize.min.js.map" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3381
+ })))
3382
+ http .Handle ("/js/angular-sanitize.min.js.map" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3382
3383
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "js" , "angular-sanitize-1.7.8.min.js.map" ))
3383
- }))
3384
- http .HandleFunc ("/js/local.js" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3384
+ })))
3385
+ http .Handle ("/js/local.js" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3385
3386
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "js" , "local.js" ))
3386
- }))
3387
- http .HandleFunc ("/js/lock-11.14.1.min.js" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3387
+ })))
3388
+ http .Handle ("/js/lock-11.14.1.min.js" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3388
3389
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "js" , "lock-11.14.1.min.js" ))
3389
- }))
3390
- http .HandleFunc ("/js/lock.min.js.map" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3390
+ })))
3391
+ http .Handle ("/js/lock.min.js.map" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3391
3392
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "js" , "lock-11.14.1.min.js.map" ))
3392
- }))
3393
- http .HandleFunc ("/js/ui-bootstrap-tpls-2.5.0.min.js" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3393
+ })))
3394
+ http .Handle ("/js/ui-bootstrap-tpls-2.5.0.min.js" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3394
3395
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "js" , "ui-bootstrap-tpls-2.5.0.min.js" ))
3395
- }))
3396
+ })))
3396
3397
3397
3398
// Other static files
3398
- http .HandleFunc ("/images/auth0.svg" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3399
+ http .Handle ("/images/auth0.svg" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3399
3400
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "images" , "auth0.svg" ))
3400
- }))
3401
- http .HandleFunc ("/images/sqlitebrowser.svg" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3401
+ })))
3402
+ http .Handle ("/images/sqlitebrowser.svg" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3402
3403
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "images" , "sqlitebrowser.svg" ))
3403
- }))
3404
- http .HandleFunc ("/favicon.ico" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3404
+ })))
3405
+ http .Handle ("/favicon.ico" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3405
3406
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "favicon.ico" ))
3406
- }))
3407
- http .HandleFunc ("/robots.txt" , logReq (func (w http.ResponseWriter , r * http.Request ) {
3407
+ })))
3408
+ http .Handle ("/robots.txt" , gz . GzipHandler ( logReq (func (w http.ResponseWriter , r * http.Request ) {
3408
3409
http .ServeFile (w , r , filepath .Join (com .Conf .Web .BaseDir , "webui" , "robots.txt" ))
3409
- }))
3410
+ })))
3410
3411
3411
3412
// Start webUI server
3412
3413
log .Printf ("DBHub server starting on https://%s\n " , com .Conf .Web .ServerName )
0 commit comments