diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-01-26 23:36:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-26 16:36:53 +0100 |
commit | 6433ba0ec3dfde67f45267aa12bd713c4a44c740 (patch) | |
tree | 8813388f7e58ff23ad24af9ccbdb5f0350cb3a09 /docs/content | |
parent | 3adbbb4255c42cde04d59b6ebf5ead7e3edda3e7 (diff) | |
download | gitea-6433ba0ec3dfde67f45267aa12bd713c4a44c740.tar.gz gitea-6433ba0ec3dfde67f45267aa12bd713c4a44c740.zip |
Move macaron to chi (#14293)
Use [chi](https://github.com/go-chi/chi) instead of the forked [macaron](https://gitea.com/macaron/macaron). Since macaron and chi have conflicts with session share, this big PR becomes a have-to thing. According my previous idea, we can replace macaron step by step but I'm wrong. :( Below is a list of big changes on this PR.
- [x] Define `context.ResponseWriter` interface with an implementation `context.Response`.
- [x] Use chi instead of macaron, and also a customize `Route` to wrap chi so that the router usage is similar as before.
- [x] Create different routers for `web`, `api`, `internal` and `install` so that the codes will be more clear and no magic .
- [x] Use https://github.com/unrolled/render instead of macaron's internal render
- [x] Use https://github.com/NYTimes/gziphandler instead of https://gitea.com/macaron/gzip
- [x] Use https://gitea.com/go-chi/session which is a modified version of https://gitea.com/macaron/session and removed `nodb` support since it will not be maintained. **BREAK**
- [x] Use https://gitea.com/go-chi/captcha which is a modified version of https://gitea.com/macaron/captcha
- [x] Use https://gitea.com/go-chi/cache which is a modified version of https://gitea.com/macaron/cache
- [x] Use https://gitea.com/go-chi/binding which is a modified version of https://gitea.com/macaron/binding
- [x] Use https://github.com/go-chi/cors instead of https://gitea.com/macaron/cors
- [x] Dropped https://gitea.com/macaron/i18n and make a new one in `code.gitea.io/gitea/modules/translation`
- [x] Move validation form structs from `code.gitea.io/gitea/modules/auth` to `code.gitea.io/gitea/modules/forms` to avoid dependency cycle.
- [x] Removed macaron log service because it's not need any more. **BREAK**
- [x] All form structs have to be get by `web.GetForm(ctx)` in the route function but not as a function parameter on routes definition.
- [x] Move Git HTTP protocol implementation to use routers directly.
- [x] Fix the problem that chi routes don't support trailing slash but macaron did.
- [x] `/api/v1/swagger` now will be redirect to `/api/swagger` but not render directly so that `APIContext` will not create a html render.
Notices:
- Chi router don't support request with trailing slash
- Integration test `TestUserHeatmap` maybe mysql version related. It's failed on my macOS(mysql 5.7.29 installed via brew) but succeed on CI.
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'docs/content')
-rw-r--r-- | docs/content/doc/advanced/config-cheat-sheet.en-us.md | 6 | ||||
-rw-r--r-- | docs/content/doc/advanced/logging-documentation.en-us.md | 37 | ||||
-rw-r--r-- | docs/content/page/index.en-us.md | 2 | ||||
-rwxr-xr-x | docs/content/page/index.fr-fr.md | 2 | ||||
-rw-r--r-- | docs/content/page/index.zh-cn.md | 2 | ||||
-rw-r--r-- | docs/content/page/index.zh-tw.md | 2 |
6 files changed, 10 insertions, 41 deletions
diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 5d2670151c..e8866ab333 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -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. @@ -609,8 +609,6 @@ 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\]`. @@ -618,7 +616,7 @@ NB: You must `REDIRECT_MACARON_LOG` and have `DISABLE_ROUTER_LOG` set to `false` - `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. diff --git a/docs/content/doc/advanced/logging-documentation.en-us.md b/docs/content/doc/advanced/logging-documentation.en-us.md index bf9fc48881..195820329d 100644 --- a/docs/content/doc/advanced/logging-documentation.en-us.md +++ b/docs/content/doc/advanced/logging-documentation.en-us.md @@ -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 @@ -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 diff --git a/docs/content/page/index.en-us.md b/docs/content/page/index.en-us.md index d190b20ae5..6bf163ecbc 100644 --- a/docs/content/page/index.en-us.md +++ b/docs/content/page/index.en-us.md @@ -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/) diff --git a/docs/content/page/index.fr-fr.md b/docs/content/page/index.fr-fr.md index 4bbf08c4d9..17e22e8b59 100755 --- a/docs/content/page/index.fr-fr.md +++ b/docs/content/page/index.fr-fr.md @@ -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/) diff --git a/docs/content/page/index.zh-cn.md b/docs/content/page/index.zh-cn.md index 453715a84d..cb6a1da793 100644 --- a/docs/content/page/index.zh-cn.md +++ b/docs/content/page/index.zh-cn.md @@ -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/) diff --git a/docs/content/page/index.zh-tw.md b/docs/content/page/index.zh-tw.md index 4c7979f41c..86c182a7d0 100644 --- a/docs/content/page/index.zh-tw.md +++ b/docs/content/page/index.zh-tw.md @@ -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/) |