Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move macaron to chi #14293

Merged
merged 83 commits into from Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
5d9a7d6
Move macaron to chi
lunny Jan 10, 2021
3791159
more contexts
lunny Jan 11, 2021
a870880
Add web sub package
lunny Jan 11, 2021
5f3f7db
Implement Combo
lunny Jan 12, 2021
541a456
Remove some macaron middlewares
lunny Jan 12, 2021
2eedb08
Some code improvements
lunny Jan 12, 2021
e3cda87
remove csrf
lunny Jan 12, 2021
9fb1af2
remove dependent for macaron
lunny Jan 12, 2021
ae7c756
Use github.com/NYTimes/gziphandler as gzip middleware
lunny Jan 12, 2021
4d1f8ba
Use github.com/go-chi/cors instead macaron/cors
lunny Jan 12, 2021
03a4fdb
Fix bugs
lunny Jan 12, 2021
330960e
Fix bugs
lunny Jan 13, 2021
8e18e9b
Remove macaron
lunny Jan 13, 2021
8785be3
Add back missed codes
lunny Jan 13, 2021
a062217
Fix lints
lunny Jan 13, 2021
9914365
Fix lint
lunny Jan 13, 2021
8b45605
Remove unused codes
lunny Jan 13, 2021
f374953
Fix lint
lunny Jan 13, 2021
4cde7ee
Fix bug
lunny Jan 13, 2021
30f269b
Fix check
lunny Jan 13, 2021
e258b22
fix bug
lunny Jan 14, 2021
5deaab1
Remove unused codes
lunny Jan 14, 2021
23772c3
Some code improvements
lunny Jan 14, 2021
588dad0
Fix bug
lunny Jan 14, 2021
8b1582f
Add back missed codes
lunny Jan 14, 2021
8cd8cfc
Less changes on PR
lunny Jan 14, 2021
589ba8f
make review easier
lunny Jan 14, 2021
5ef8a14
Fix test
lunny Jan 14, 2021
aa66b49
Fix bug
lunny Jan 15, 2021
a9df33a
Fix route conflicted with group
lunny Jan 16, 2021
8322e49
Fix lint
lunny Jan 16, 2021
de924cc
Fix route group
lunny Jan 16, 2021
c2802c0
Remove unused packages
lunny Jan 16, 2021
a38f19d
Fix routes
lunny Jan 16, 2021
028e53b
rollback unnecessary changes
lunny Jan 16, 2021
efcb1ce
Fix routes
lunny Jan 16, 2021
7e16579
Remove macaron log
lunny Jan 16, 2021
2fe6263
Fix csrf
lunny Jan 16, 2021
dba9a10
Fix some bugs
lunny Jan 16, 2021
46547f3
Fix lint
lunny Jan 16, 2021
7ca059b
Fix bug
lunny Jan 16, 2021
e7db727
Swagger API
lunny Jan 16, 2021
e29896f
Fix render bugs
lunny Jan 16, 2021
4262725
Fix login
lunny Jan 16, 2021
c9fd755
Move http protocol to use chi routers
lunny Jan 18, 2021
64e2dc8
Fix lint and fix Query functions
lunny Jan 18, 2021
6332390
Fix bug
lunny Jan 18, 2021
36c2760
Change how to get router function form parameters
lunny Jan 18, 2021
7ea7a58
Fix bug
lunny Jan 18, 2021
178e084
Fix lint and test
lunny Jan 18, 2021
4c5cd50
Fix vendor
lunny Jan 19, 2021
81bd4dc
Fix test
lunny Jan 19, 2021
2d4bfbe
Fix tests
lunny Jan 19, 2021
8759e45
Fix test
lunny Jan 19, 2021
fe5072a
A new response writer
lunny Jan 19, 2021
fff409d
Improve codes
lunny Jan 20, 2021
5723702
Fix test
lunny Jan 20, 2021
f0e11c9
Fix test
lunny Jan 20, 2021
2776c68
Fix bug
lunny Jan 20, 2021
572af45
Fix lint
lunny Jan 21, 2021
ca14f01
Fix lint
lunny Jan 21, 2021
fc1b0dc
Fix tests
lunny Jan 21, 2021
994cbfc
Fix tests
lunny Jan 21, 2021
5431f03
Fix tests
lunny Jan 22, 2021
559e713
Fix bug
lunny Jan 22, 2021
2c5f58a
Fix bug
lunny Jan 22, 2021
3196ca3
Fix tests
lunny Jan 22, 2021
1a185a4
Fix lint
lunny Jan 22, 2021
64340eb
Fix tests
lunny Jan 24, 2021
5414325
Fix lint
lunny Jan 24, 2021
fae18e0
Recovery unnecessary change
lunny Jan 24, 2021
3825d67
Recovery unnecessary change
lunny Jan 24, 2021
958c529
Fix bug
lunny Jan 24, 2021
4d00a72
fix swagger redirect
6543 Jan 24, 2021
7d84821
correct err msg
6543 Jan 24, 2021
b1edd78
remove nodb completly
6543 Jan 24, 2021
9be33ca
fix swagger redirect (secnd)
6543 Jan 24, 2021
89d62de
Merge branch 'master' into pr
6543 Jan 25, 2021
4507553
Some code improvements
lunny Jan 25, 2021
7ed6d56
Move default recovery before session middleware so that the panic on …
lunny Jan 25, 2021
5df82c0
Merge branch 'master' into lunny/routes2
lafriks Jan 26, 2021
2c71a3d
return error
6543 Jan 26, 2021
618cd43
temporary fix until ci update translations
6543 Jan 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .golangci.yml
Expand Up @@ -70,7 +70,7 @@ issues:
- path: modules/log/
linters:
- errcheck
- path: routers/routes/macaron.go
- path: routers/routes/web.go
linters:
- dupl
- path: routers/api/v1/repo/issue_subscription.go
Expand Down
2 changes: 1 addition & 1 deletion cmd/dump.go
Expand Up @@ -21,7 +21,7 @@ import (
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/util"

"gitea.com/macaron/session"
"gitea.com/go-chi/session"
archiver "github.com/mholt/archiver/v3"
"github.com/urfave/cli"
)
Expand Down
9 changes: 3 additions & 6 deletions cmd/web.go
Expand Up @@ -102,8 +102,7 @@ func runWeb(ctx *cli.Context) error {
return err
}
}
c := routes.NewChi()
routes.RegisterInstallRoute(c)
c := routes.InstallRoutes()
err := listen(c, false)
select {
case <-graceful.GetManager().IsShutdown():
Expand Down Expand Up @@ -134,11 +133,9 @@ func runWeb(ctx *cli.Context) error {
return err
}
}
// Set up Chi routes
c := routes.NewChi()
c.Mount("/", routes.NormalRoutes())
routes.DelegateToMacaron(c)

// Set up Chi routes
c := routes.NormalRoutes()
err := listen(c, true)
<-graceful.GetManager().Done()
log.Info("PID: %d Gitea Web Finished", os.Getpid())
Expand Down
4 changes: 1 addition & 3 deletions contrib/pr/checkout.go
Expand Up @@ -116,9 +116,7 @@ func runPR() {
//routers.GlobalInit()
external.RegisterParsers()
markup.Init()
c := routes.NewChi()
c.Mount("/", routes.NormalRoutes())
routes.DelegateToMacaron(c)
c := routes.NormalRoutes()

log.Printf("[PR] Ready for testing !\n")
log.Printf("[PR] Login with user1, user2, user3, ... with pass: password\n")
Expand Down
6 changes: 2 additions & 4 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Expand Up @@ -549,7 +549,7 @@ Define allowed algorithms and their minimum key length (use -1 to disable a type

## Session (`session`)

- `PROVIDER`: **memory**: Session engine provider \[memory, file, redis, mysql, couchbase, memcache, nodb, postgres\].
- `PROVIDER`: **memory**: Session engine provider \[memory, file, redis, mysql, couchbase, memcache, postgres\].
- `PROVIDER_CONFIG`: **data/sessions**: For file, the root path; for others, the connection string.
- `COOKIE_SECURE`: **false**: Enable this to force using HTTPS for all session access.
- `COOKIE_NAME`: **i\_like\_gitea**: The name of the cookie used for the session ID.
Expand Down Expand Up @@ -609,16 +609,14 @@ Default templates for project boards:
- `MODE`: **console**: Logging mode. For multiple modes, use a comma to separate values. You can configure each mode in per mode log subsections `\[log.modename\]`. By default the file mode will log to `$ROOT_PATH/gitea.log`.
- `LEVEL`: **Info**: General log level. \[Trace, Debug, Info, Warn, Error, Critical, Fatal, None\]
- `STACKTRACE_LEVEL`: **None**: Default log level at which to log create stack traces. \[Trace, Debug, Info, Warn, Error, Critical, Fatal, None\]
- `REDIRECT_MACARON_LOG`: **false**: Redirects the Macaron log to its own logger or the default logger.
- `MACARON`: **file**: Logging mode for the macaron logger, use a comma to separate values. Configure each mode in per mode log subsections `\[log.modename.macaron\]`. By default the file mode will log to `$ROOT_PATH/macaron.log`. (If you set this to `,` it will log to default gitea logger.)
- `ROUTER_LOG_LEVEL`: **Info**: The log level that the router should log at. (If you are setting the access log, its recommended to place this at Debug.)
- `ROUTER`: **console**: The mode or name of the log the router should log to. (If you set this to `,` it will log to default gitea logger.)
NB: You must `REDIRECT_MACARON_LOG` and have `DISABLE_ROUTER_LOG` set to `false` for this option to take effect. Configure each mode in per mode log subsections `\[log.modename.router\]`.
- `ENABLE_ACCESS_LOG`: **false**: Creates an access.log in NCSA common log format, or as per the following template
- `ACCESS`: **file**: Logging mode for the access logger, use a comma to separate values. Configure each mode in per mode log subsections `\[log.modename.access\]`. By default the file mode will log to `$ROOT_PATH/access.log`. (If you set this to `,` it will log to the default gitea logger.)
- `ACCESS_LOG_TEMPLATE`: **`{{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"`**: Sets the template used to create the access log.
- The following variables are available:
- `Ctx`: the `macaron.Context` of the request.
- `Ctx`: the `context.Context` of the request.
- `Identity`: the SignedUserName or `"-"` if not logged in.
- `Start`: the start time of the request.
- `ResponseWriter`: the responseWriter from the request.
Expand Down
37 changes: 4 additions & 33 deletions docs/content/doc/advanced/logging-documentation.en-us.md
Expand Up @@ -67,40 +67,11 @@ The provider type of the sublogger can be set using the `MODE` value in
its subsection, but will default to the name. This allows you to have
multiple subloggers that will log to files.

### The "Macaron" logger

By default Macaron will log to its own go `log` instance. This writes
to `os.Stdout`. You can redirect this log to a Gitea configurable logger
through setting the `REDIRECT_MACARON_LOG` setting in the `[log]`
section which you can configure the outputs of by setting the `MACARON`
value in the `[log]` section of the configuration. `MACARON` defaults
to `file` if unset.

Please note, the macaron logger will log at `INFO` level, setting the
`LEVEL` of this logger to `WARN` or above will result in no macaron logs.

Each output sublogger for this logger is configured in
`[log.sublogger.macaron]` sections. There are certain default values
which will not be inherited from the `[log]` or relevant
`[log.sublogger]` sections:

- `FLAGS` is `stdflags` (Equal to
`date,time,medfile,shortfuncname,levelinitial`)
- `FILE_NAME` will default to `%(ROOT_PATH)/macaron.log`
- `EXPRESSION` will default to `""`
- `PREFIX` will default to `""`

NB: You can redirect the macaron logger to send its events to the gitea
log using the value: `MACARON = ,`

### The "Router" logger

There are two types of Router log. By default Macaron send its own
router log which will be directed to Macaron's go `log`, however if you
`REDIRECT_MACARON_LOG` you will enable Gitea's router log. You can
disable both types of Router log by setting `DISABLE_ROUTER_LOG`.
You can disable Router log by setting `DISABLE_ROUTER_LOG`.

If you enable the redirect, you can configure the outputs of this
You can configure the outputs of this
router log by setting the `ROUTER` value in the `[log]` section of the
configuration. `ROUTER` will default to `console` if unset. The Gitea
Router logs the same data as the Macaron log but has slightly different
Expand Down Expand Up @@ -162,11 +133,11 @@ This value represent a go template. It's default value is:

The template is passed following options:

- `Ctx` is the `macaron.Context`
- `Ctx` is the `context.Context`
- `Identity` is the `SignedUserName` or `"-"` if the user is not logged
in
- `Start` is the start time of the request
- `ResponseWriter` is the `macaron.ResponseWriter`
- `ResponseWriter` is the `http.ResponseWriter`

Caution must be taken when changing this template as it runs outside of
the standard panic recovery trap. The template should also be as simple
Expand Down
2 changes: 1 addition & 1 deletion docs/content/page/index.en-us.md
Expand Up @@ -267,7 +267,7 @@ Windows, on architectures like amd64, i386, ARM, PowerPC, and others.

## Components

* Web framework: [Macaron](http://go-macaron.com/)
* Web framework: [Chi](http://github.com/go-chi/chi)
* ORM: [XORM](https://xorm.io)
* UI components:
* [Semantic UI](http://semantic-ui.com/)
Expand Down
2 changes: 1 addition & 1 deletion docs/content/page/index.fr-fr.md
Expand Up @@ -254,7 +254,7 @@ Le but de ce projet est de fournir de la manière la plus simple, la plus rapide

## Composants

* Framework web : [Macaron](http://go-macaron.com/)
* Framework web : [Chi](http://github.com/go-chi/chi)
* ORM: [XORM](https://xorm.io)
* Interface graphique :
* [Semantic UI](http://semantic-ui.com/)
Expand Down
2 changes: 1 addition & 1 deletion docs/content/page/index.zh-cn.md
Expand Up @@ -47,7 +47,7 @@ Gitea的首要目标是创建一个极易安装,运行非常快速,安装和

## 组件

* Web框架: [Macaron](http://go-macaron.com/)
* Web框架: [Chi](http://github.com/go-chi/chi)
* ORM: [XORM](https://xorm.io)
* UI组件:
* [Semantic UI](http://semantic-ui.com/)
Expand Down
2 changes: 1 addition & 1 deletion docs/content/page/index.zh-tw.md
Expand Up @@ -47,7 +47,7 @@ Gitea 的首要目標是建立一個容易安裝,運行快速,安装和使

## 元件

* Web 框架: [Macaron](http://go-macaron.com/)
* Web 框架: [Chi](http://github.com/go-chi/chi)
* ORM: [XORM](https://xorm.io)
* UI 元件:
* [Semantic UI](http://semantic-ui.com/)
Expand Down
16 changes: 5 additions & 11 deletions go.mod
Expand Up @@ -5,19 +5,12 @@ go 1.14
require (
code.gitea.io/gitea-vet v0.2.1
code.gitea.io/sdk/gitea v0.13.1
gitea.com/go-chi/binding v0.0.0-20210113025129-03f1d313373c
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e
gitea.com/go-chi/captcha v0.0.0-20210110083842-e7696c336a1e
gitea.com/go-chi/session v0.0.0-20210108030337-0cb48c5ba8ee
gitea.com/lunny/levelqueue v0.3.0
gitea.com/macaron/binding v0.0.0-20190822013154-a5f53841ed2b
gitea.com/macaron/cache v0.0.0-20200924044943-905232fba10b
gitea.com/macaron/captcha v0.0.0-20200825161008-e8597820aaca
gitea.com/macaron/cors v0.0.0-20190826180238-95aec09ea8b4
gitea.com/macaron/csrf v0.0.0-20190822024205-3dc5a4474439
gitea.com/macaron/gzip v0.0.0-20200827120000-efa5e8477cf5
gitea.com/macaron/i18n v0.0.0-20200911004404-4ca3dd0cbd60
gitea.com/macaron/inject v0.0.0-20190805023432-d4c86e31027a
gitea.com/macaron/macaron v1.5.1-0.20201027213641-0db5d4584804
gitea.com/macaron/session v0.0.0-20201103015045-a177a2701dee
gitea.com/macaron/toolbox v0.0.0-20190822013122-05ff0fc766b7
github.com/NYTimes/gziphandler v1.1.1
github.com/PuerkitoBio/goquery v1.5.1
github.com/RoaringBitmap/roaring v0.5.5 // indirect
github.com/alecthomas/chroma v0.8.2
Expand All @@ -36,6 +29,7 @@ require (
github.com/gliderlabs/ssh v0.3.1
github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a // indirect
github.com/go-chi/chi v1.5.1
github.com/go-chi/cors v1.1.1
github.com/go-enry/go-enry/v2 v2.6.0
github.com/go-git/go-billy/v5 v5.0.0
github.com/go-git/go-git/v5 v5.2.0
Expand Down