-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support of russian language (#267)
* Added security headers docs * Added support of russian language
- Loading branch information
KostLinux
authored
Apr 18, 2024
1 parent
78dafed
commit 95da710
Showing
68 changed files
with
2,830 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
+++ | ||
title = "Gin Web Framework" | ||
linkTitle = "Gin Web Framework" | ||
+++ | ||
|
||
{{< blocks/cover title="Gin Web Framework" image_anchor="top" height="full" color="orange" >}} | ||
<div class="mx-auto"> | ||
<a class="btn btn-lg btn-primary mr-3 mb-4" href="{{< relref "/docs" >}}"> | ||
Подробнее <i class="fas fa-arrow-alt-circle-right ml-2"></i> | ||
</a> | ||
<a class="btn btn-lg btn-secondary mr-3 mb-4" href="https://github.com/gin-gonic/gin/releases"> | ||
Скачать <i class="fab fa-github ml-2 "></i> | ||
</a> | ||
<p class="lead mt-5">Самый быстрый полнофункциональный веб-фреймворк для Go. Кристально чистый.</p> | ||
<div class="mx-auto mt-5"/> | ||
{{< blocks/link-down color="info" >}} | ||
</div> | ||
{{< /blocks/cover >}} | ||
|
||
|
||
{{% blocks/lead color="white" %}} | ||
|
||
**Что такое Gin?** | ||
|
||
Gin - это веб-фреймворк, написанный на языке Golang. | ||
|
||
В нем реализован API, похожий на Martini, но производительность в 40 раз выше, чем у Martini. | ||
|
||
Если вам нужна производительность и продуктивность, Gin вам понравится. | ||
|
||
{{% /blocks/lead %}} | ||
|
||
{{< blocks/section color="light" >}} | ||
|
||
{{% blocks/feature icon="fa fa-tachometer-alt" title="Fast" %}} | ||
Маршрутизация на основе радиксного дерева, малый объем памяти. Никаких отражений. Предсказуемая производительность API. | ||
{{% /blocks/feature %}} | ||
|
||
{{% blocks/feature icon="fa fa-bars" title="Middleware support" %}} | ||
Входящий HTTP-запрос может быть обработан цепочкой промежуточного ПО (Middleware) и конечным действием. | ||
Например: Логгер, авторизация, GZIP и, наконец, публикация сообщения в БД. | ||
{{% /blocks/feature %}} | ||
|
||
{{% blocks/feature icon="fa fa-life-ring" title="Crash-free" %}} | ||
Gin может поймать панику, возникшую во время HTTP-запроса, и восстановить ее. Таким образом, ваш сервер будет всегда доступен. Также можно сообщить об этой панике, например, в Sentry! | ||
{{% /blocks/feature %}} | ||
|
||
{{< /blocks/section >}} | ||
|
||
{{< blocks/section color="white" >}} | ||
|
||
{{% blocks/feature icon="fa fa-check-circle" title="JSON validation" %}} | ||
Gin может анализировать и проверять JSON-запросы, например, на наличие необходимых значений. | ||
{{% /blocks/feature %}} | ||
|
||
{{% blocks/feature icon="fa fa-users-cog" title="Routes grouping" %}} | ||
Организуйте свои маршруты лучше. Требуется и не требуется авторизация, разные версии API. Кроме того, группы могут быть вложены бесконечно без снижения производительности. | ||
{{% /blocks/feature %}} | ||
|
||
|
||
{{% blocks/feature icon="fa fa-briefcase" title="Error management" %}} | ||
Gin обеспечивает удобный способ сбора всех ошибок, возникших во время HTTP-запроса. В конечном итоге промежуточное ПО (Middleware) может записывать их в файл журнала, в базу данных и отправлять через сеть. | ||
{{% /blocks/feature %}} | ||
|
||
{{< /blocks/section >}} | ||
|
||
{{< blocks/section color="info" >}} | ||
|
||
{{% blocks/feature icon="fa fa-images" title="Rendering built-in" %}} | ||
Gin предоставляет простой в использовании API для рендеринга JSON, XML и HTML. | ||
{{% /blocks/feature %}} | ||
|
||
{{% blocks/feature icon="fa fa-code" title="Extendable" %}} | ||
Создать новое промежуточное программное обеспечение очень просто, просто посмотрите пример кода. | ||
{{% /blocks/feature %}} | ||
|
||
{{< /blocks/section >}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: "Blog" | ||
linkTitle: "Blog" | ||
menu: | ||
main: | ||
weight: 30 | ||
--- | ||
|
||
|
||
This is the **blog** section. It has two categories: News and Releases. | ||
|
||
Files in these directories will be listed in reverse chronological order. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
--- | ||
title: "Новости" | ||
linkTitle: "News" | ||
weight: 20 | ||
--- | ||
|
||
|
143 changes: 143 additions & 0 deletions
143
content/ru/blog/news/how-to-build-one-effective-middleware.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
--- | ||
title: "Как создать эффективное промежуточное программное обеспечение? (Middleware)" | ||
linkTitle: "How to build one effective middleware?" | ||
date: 2019-02-26 | ||
--- | ||
|
||
## Constituent parts | ||
|
||
Промежуточное ПО (Middleware) состоит из двух частей: | ||
|
||
- первая часть - это то, что выполняется один раз, когда вы инициализируете промежуточное ПО. В ней вы устанавливаете все глобальные объекты, логики и т. д. Все это происходит один раз за время жизни приложения. | ||
|
||
- Вторая часть - это то, что выполняется при каждом запросе. Например, в промежуточном ПО для работы с базами данных вы просто вводите свой "глобальный" объект базы данных в контекст. Как только он окажется внутри контекста, вы сможете получить его из других промежуточных модулей и из вашей функции-обработчика. | ||
|
||
```go | ||
func funcName(params string) gin.HandlerFunc { | ||
// <--- | ||
// This is part one | ||
// ---> | ||
// The following code is an example | ||
if err := check(params); err != nil { | ||
panic(err) | ||
} | ||
|
||
return func(c *gin.Context) { | ||
// <--- | ||
// This is part two | ||
// ---> | ||
// The following code is an example | ||
c.Set("TestVar", params) | ||
c.Next() | ||
} | ||
} | ||
``` | ||
|
||
## Процесс выполнения | ||
|
||
Во-первых, у нас есть следующий пример кода: | ||
|
||
```go | ||
func main() { | ||
router := gin.Default() | ||
|
||
router.Use(globalMiddleware()) | ||
|
||
router.GET("/rest/n/api/*some", mid1(), mid2(), handler) | ||
|
||
router.Run() | ||
} | ||
|
||
func globalMiddleware() gin.HandlerFunc { | ||
fmt.Println("globalMiddleware...1") | ||
|
||
return func(c *gin.Context) { | ||
fmt.Println("globalMiddleware...2") | ||
c.Next() | ||
fmt.Println("globalMiddleware...3") | ||
} | ||
} | ||
|
||
func handler(c *gin.Context) { | ||
fmt.Println("exec handler.") | ||
} | ||
|
||
func mid1() gin.HandlerFunc { | ||
fmt.Println("mid1...1") | ||
|
||
return func(c *gin.Context) { | ||
|
||
fmt.Println("mid1...2") | ||
c.Next() | ||
fmt.Println("mid1...3") | ||
} | ||
} | ||
|
||
func mid2() gin.HandlerFunc { | ||
fmt.Println("mid2...1") | ||
|
||
return func(c *gin.Context) { | ||
fmt.Println("mid2...2") | ||
c.Next() | ||
fmt.Println("mid2...3") | ||
} | ||
} | ||
``` | ||
|
||
Согласно [Составные части](#Constituent-parts), когда мы запускаем процесс джина, **часть первая** будет выполняться первой и выведет следующую информацию: | ||
|
||
```go | ||
globalMiddleware...1 | ||
mid1...1 | ||
mid2...1 | ||
``` | ||
|
||
And init order is: | ||
|
||
```go | ||
globalMiddleware...1 | ||
| | ||
v | ||
mid1...1 | ||
| | ||
v | ||
mid2...1 | ||
``` | ||
|
||
Когда мы выполним один запрос `curl -v localhost:8080/rest/n/api/some`, **часть вторая** выполнит свое промежуточное ПО и выведет следующую информацию: | ||
|
||
```go | ||
globalMiddleware...2 | ||
mid1...2 | ||
mid2...2 | ||
exec handler. | ||
mid2...3 | ||
mid1...3 | ||
globalMiddleware...3 | ||
``` | ||
|
||
Другими словами, порядок выполнения таков: | ||
|
||
```go | ||
globalMiddleware...2 | ||
| | ||
v | ||
mid1...2 | ||
| | ||
v | ||
mid2...2 | ||
| | ||
v | ||
exec handler. | ||
| | ||
v | ||
mid2...3 | ||
| | ||
v | ||
mid1...3 | ||
| | ||
v | ||
globalMiddleware...3 | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
--- | ||
title: "Релизы" | ||
linkTitle: "Releases" | ||
weight: 20 | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: "Gin 1.3.0 is released" | ||
linkTitle: "Gin 1.3.0 is released" | ||
date: 2018-08-14 | ||
--- | ||
|
||
### CHANGELOG | ||
|
||
- [NEW] Add [`func (*Context) QueryMap`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.QueryMap), [`func (*Context) GetQueryMap`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.GetQueryMap), [`func (*Context) PostFormMap`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.PostFormMap) and [`func (*Context) GetPostFormMap`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.GetPostFormMap) to support `type map[string]string` as query string or form parameters, see [#1383](https://github.com/gin-gonic/gin/pull/1383) | ||
- [NEW] Add [`func (*Context) AsciiJSON`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.AsciiJSON), see [#1358](https://github.com/gin-gonic/gin/pull/1358) | ||
- [NEW] Add `Pusher()` in [`type ResponseWriter`](https://pkg.go.dev/github.com/gin-gonic/gin#ResponseWriter) for supporting http2 push, see [#1273](https://github.com/gin-gonic/gin/pull/1273) | ||
- [NEW] Add [`func (*Context) DataFromReader`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.DataFromReader) for serving dynamic data, see [#1304](https://github.com/gin-gonic/gin/pull/1304) | ||
- [NEW] Add [`func (*Context) ShouldBindBodyWith`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.ShouldBindBodyWith) allowing to call binding multiple times, see [#1341](https://github.com/gin-gonic/gin/pull/1341) | ||
- [NEW] Support pointers in form binding, see [#1336](https://github.com/gin-gonic/gin/pull/1336) | ||
- [NEW] Add [`func (*Context) JSONP`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.JSONP), see [#1333](https://github.com/gin-gonic/gin/pull/1333) | ||
- [NEW] Support default value in form binding, see [#1138](https://github.com/gin-gonic/gin/pull/1138) | ||
- [NEW] Expose validator engine in [`type StructValidator`](https://pkg.go.dev/github.com/gin-gonic/gin/binding#StructValidator), see [#1277](https://github.com/gin-gonic/gin/pull/1277) | ||
- [NEW] Add [`func (*Context) ShouldBind`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.ShouldBind), [`func (*Context) ShouldBindQuery`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.ShouldBindQuery) and [`func (*Context) ShouldBindJSON`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.ShouldBindJSON), see [#1047](https://github.com/gin-gonic/gin/pull/1047) | ||
- [NEW] Add support for `time.Time` location in form binding, see [#1117](https://github.com/gin-gonic/gin/pull/1117) | ||
- [NEW] Add [`func (*Context) BindQuery`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.BindQuery), see [#1029](https://github.com/gin-gonic/gin/pull/1029) | ||
- [NEW] Make [jsonite](https://github.com/json-iterator/go) optional with build tags, see [#1026](https://github.com/gin-gonic/gin/pull/1026) | ||
- [NEW] Show query string in logger, see [#999](https://github.com/gin-gonic/gin/pull/999) | ||
- [NEW] Add [`func (*Context) SecureJSON`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.SecureJSON), see [#987](https://github.com/gin-gonic/gin/pull/987) and [#993](https://github.com/gin-gonic/gin/pull/993) | ||
- [DEPRECATE] `func (*Context) GetCookie` for [`func (*Context) Cookie`](https://pkg.go.dev/github.com/gin-gonic/gin#Context.Cookie) | ||
- [FIX] Don't display color tags if [`func DisableConsoleColor`](https://pkg.go.dev/github.com/gin-gonic/gin#DisableConsoleColor) called, see [#1072](https://github.com/gin-gonic/gin/pull/1072) | ||
- [FIX] Gin Mode `""` when calling [`func Mode`](https://pkg.go.dev/github.com/gin-gonic/gin#Mode) now returns `const DebugMode`, see [#1250](https://github.com/gin-gonic/gin/pull/1250) | ||
- [FIX] `Flush()` now doesn't overwrite `responseWriter` status code, see [#1460](https://github.com/gin-gonic/gin/pull/1460) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
title: "Gin 1.4.0 is released" | ||
linkTitle: "Gin 1.4.0 is released" | ||
date: 2019-05-08 | ||
--- | ||
|
||
### CHANGELOG | ||
|
||
#### Feature | ||
|
||
- [NEW] Support for [Go Modules](https://github.com/golang/go/wiki/Modules) [#1569](https://github.com/gin-gonic/gin/pull/1569) | ||
- [NEW] Refactor of form mapping multipart request [#1829](https://github.com/gin-gonic/gin/pull/1829) | ||
- [NEW] Supporting file binding [#1264](https://github.com/gin-gonic/gin/pull/1264) | ||
- [NEW] Add support for mapping arrays [#1797](https://github.com/gin-gonic/gin/pull/1797) | ||
- [NEW] Make context.Keys available as LogFormatterParams [#1779](https://github.com/gin-gonic/gin/pull/1779) | ||
- [NEW] Use internal/json for Marshal/Unmarshal [#1791](https://github.com/gin-gonic/gin/pull/1791) | ||
- [NEW] Support mapping time.Duration [#1794](https://github.com/gin-gonic/gin/pull/1794) | ||
- [NEW] Refactor form mappings [#1749](https://github.com/gin-gonic/gin/pull/1749) | ||
- [NEW] Added flag to context.Stream indicates if client disconnected in middle of stream [#1252](https://github.com/gin-gonic/gin/pull/1252) | ||
- [NEW] Extend context.File to allow for the content-dispositon attachments via a new method context.Attachment [#1260](https://github.com/gin-gonic/gin/pull/1260) | ||
- [NEW] Add prefix from X-Forwarded-Prefix in redirectTrailingSlash [#1238](https://github.com/gin-gonic/gin/pull/1238) | ||
- [NEW] Add context.HandlerNames() [#1729](https://github.com/gin-gonic/gin/pull/1729) | ||
- [NEW] Add response size to LogFormatterParams [#1752](https://github.com/gin-gonic/gin/pull/1752) | ||
- [NEW] Allow ignoring field on form mapping [#1733](https://github.com/gin-gonic/gin/pull/1733) | ||
- [NEW] Add a function to force color in console output. [#1724](https://github.com/gin-gonic/gin/pull/1724) | ||
- [NEW] Binding for URL Params [#1694](https://github.com/gin-gonic/gin/pull/1694) | ||
- [NEW] Add LoggerWithFormatter method [#1677](https://github.com/gin-gonic/gin/pull/1677) | ||
- [NEW] RunFd method to run http.Server through a file descriptor [#1609](https://github.com/gin-gonic/gin/pull/1609) | ||
- [NEW] Yaml binding support [#1618](https://github.com/gin-gonic/gin/pull/1618) | ||
- [NEW] Add PureJSON renderer [#694](https://github.com/gin-gonic/gin/pull/694) | ||
- [NEW] Set default time format in form binding [#1487](https://github.com/gin-gonic/gin/pull/1487) | ||
- [NEW] Upgrade dependency libraries [#1491](https://github.com/gin-gonic/gin/pull/1491) | ||
|
||
#### Bug fix | ||
|
||
- [FIX] Truncate Latency precision in long running request [#1830](https://github.com/gin-gonic/gin/pull/1830) | ||
- [FIX] IsTerm flag should not be affected by DisableConsoleColor method. [#1802](https://github.com/gin-gonic/gin/pull/1802) | ||
- [FIX] Readme updates [#1793](https://github.com/gin-gonic/gin/pull/1793) [#1788](https://github.com/gin-gonic/gin/pull/1788) [1789](https://github.com/gin-gonic/gin/pull/1789) | ||
- [FIX] StaticFS: Fixed Logging two log lines on 404. [#1805](https://github.com/gin-gonic/gin/pull/1805), [#1804](https://github.com/gin-gonic/gin/pull/1804) | ||
- [FIX] Moved [examples](https://github.com/gin-gonic/examples) to stand alone Repo [#1775](https://github.com/gin-gonic/gin/pull/1775) | ||
- [FIX] Support HTTP content negotiation wildcards [#1112](https://github.com/gin-gonic/gin/pull/1112) | ||
- [FIX] Pass MaxMultipartMemory when FormFile is called [#1600](https://github.com/gin-gonic/gin/pull/1600) | ||
- [FIX] LoadHTML* tests [#1559](https://github.com/gin-gonic/gin/pull/1559) | ||
- [FIX] Removed use of sync.pool from HandleContext [#1565](https://github.com/gin-gonic/gin/pull/1565) | ||
- [FIX] Format output log to os.Stderr [#1571](https://github.com/gin-gonic/gin/pull/1571) | ||
- [FIX] Make logger use a yellow background and a darkgray text for legibility [#1570](https://github.com/gin-gonic/gin/pull/1570) | ||
- [FIX] Remove sensitive request information from panic log. [#1370](https://github.com/gin-gonic/gin/pull/1370) | ||
- [FIX] log.Println() does not print timestamp [#829](https://github.com/gin-gonic/gin/pull/829) [#1560](https://github.com/gin-gonic/gin/pull/1560) | ||
- [FIX] Add missing copyright and update if/else [#1497](https://github.com/gin-gonic/gin/pull/1497) | ||
- [FIX] Update msgpack usage [#1498](https://github.com/gin-gonic/gin/pull/1498) | ||
- [FIX] Use protobuf on render [#1496](https://github.com/gin-gonic/gin/pull/1496) | ||
- [FIX] Add support for Protobuf format response [#1479](https://github.com/gin-gonic/gin/pull/1479) | ||
- [FIX] Add BindXML and ShouldBindXML [#1485](https://github.com/gin-gonic/gin/pull/1485) | ||
- [FIX] CI testing updates [#1671](https://github.com/gin-gonic/gin/pull/1671) [#1670](https://github.com/gin-gonic/gin/pull/1670) [#1682](https://github.com/gin-gonic/gin/pull/1682) [#1669](https://github.com/gin-gonic/gin/pull/1669) | ||
- [FIX] StaticFS(): Send 404 when path does not exist [#1663](https://github.com/gin-gonic/gin/pull/1663) | ||
- [FIX] Handle nil body for JSON binding [#1638](https://github.com/gin-gonic/gin/pull/1638) | ||
- [FIX] Support bind uri param [#1612](https://github.com/gin-gonic/gin/pull/1612) | ||
- [FIX] recovery: fix issue with syscall import on google app engine [#1640](https://github.com/gin-gonic/gin/pull/1640) | ||
- [FIX] Make sure the debug log contains line breaks [#1650](https://github.com/gin-gonic/gin/pull/1650) | ||
- [FIX] Panic stack trace being printed during recovery of broken pipe [#1089](https://github.com/gin-gonic/gin/pull/1089) [#1259](https://github.com/gin-gonic/gin/pull/1259) | ||
- [FIX] Context.Next() - recheck len of handlers on every iteration. [#1745](https://github.com/gin-gonic/gin/pull/1745) | ||
- [FIX] Fix all errcheck warnings [#1739](https://github.com/gin-gonic/gin/pull/1739) [#1653](https://github.com/gin-gonic/gin/pull/1653) | ||
- [FIX] Change color methods to public in the defaultLogger. [#1771](https://github.com/gin-gonic/gin/pull/1771) | ||
- [FIX] Update writeHeaders method to use http.Header.Set [#1722](https://github.com/gin-gonic/gin/pull/1722) | ||
- [FIX] context.Copy() race condition [#1020](https://github.com/gin-gonic/gin/pull/1020) | ||
|
Oops, something went wrong.