From cfc1f382171f9aab8ef643b725bb53039722cd5b Mon Sep 17 00:00:00 2001 From: Andreas Deininger Date: Wed, 1 Jan 2025 21:29:45 +0100 Subject: [PATCH] Fix typos --- docs/core-concepts.md | 6 +++--- docs/core-services.md | 6 +++--- docs/custom-services.md | 2 +- docs/faqs.md | 4 ++-- docs/middleware/cache.md | 2 +- docs/middleware/session.md | 2 +- docs/starter-guide.md | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/core-concepts.md b/docs/core-concepts.md index 7af11be..5ad8b81 100644 --- a/docs/core-concepts.md +++ b/docs/core-concepts.md @@ -47,7 +47,7 @@ Do keep in mind that `flamego.Classic` may not always be what you want if you do The function [`flamego.New`](https://pkg.go.dev/github.com/flamego/flamego#New) is used to create bare Flame instances that do not have default middleware registered, and any type that contains the [`flamego.Flame`](https://pkg.go.dev/github.com/flamego/flamego#Flame) can be seen as a Flame instance. -Each Flame instace is independent of other Flame instances in the sense that instance state is not shared and is maintained separately by each of them. For example, you can have two Flame instances simultaneously and both of them can have different middleware, routes and handlers registered or defined: +Each Flame instance is independent of other Flame instances in the sense that instance state is not shared and is maintained separately by each of them. For example, you can have two Flame instances simultaneously and both of them can have different middleware, routes and handlers registered or defined: ```go:no-line-numbers func main() { @@ -65,7 +65,7 @@ In the above example, `f1` has some default middleware registered as a classic F ::: tip 💬 Do you agree? Storing states in the way that is polluting global namespace is such a bad practice that not only makes the code hard to maintain in the future, but also creates more tech debt with every single new line of the code. -It feels so elegent to have isolated state managed by each Flame instance, and make it possible to migrate existing web applications to use Flamego progressively. +It feels so elegant to have isolated state managed by each Flame instance, and make it possible to migrate existing web applications to use Flamego progressively. ::: ## Handlers @@ -356,7 +356,7 @@ There are services that are always injected thus available to every handler, inc Middleware are the special kind of handlers that are designed as reusable components, and often accepting configurable options. There is no difference between middleware and handlers from compiler's point of view. -Technically speaking, you may use the term middleware and handlers interchangably but the common sense would be that middleware are providing some services, either by [injecting to the context](https://github.com/flamego/session/blob/f8f1e1893ea6c15f071dd53aefd9494d41ce9e48/session.go#L183-L184) or [intercepting the request](https://github.com/flamego/auth/blob/dbec68df251ff382e908eb5659453d4918a042aa/basic.go#L38-L42), or both. On the other hand, handlers are mainly focusing on the business logic that is unique to your web application and the route that handlers are registered with. +Technically speaking, you may use the term middleware and handlers interchangeably but the common sense would be that middleware are providing some services, either by [injecting to the context](https://github.com/flamego/session/blob/f8f1e1893ea6c15f071dd53aefd9494d41ce9e48/session.go#L183-L184) or [intercepting the request](https://github.com/flamego/auth/blob/dbec68df251ff382e908eb5659453d4918a042aa/basic.go#L38-L42), or both. On the other hand, handlers are mainly focusing on the business logic that is unique to your web application and the route that handlers are registered with. Middleware can be used at anywhere that a `flamego.Handler` is accepted, including at global, group and route level. diff --git a/docs/core-services.md b/docs/core-services.md index 409c32b..8c8d073 100644 --- a/docs/core-services.md +++ b/docs/core-services.md @@ -31,7 +31,7 @@ func main() { When a route is matched by a request, the Flame instance [queues a chain of handlers](https://github.com/flamego/flamego/blob/8709b65452b2f8513508500017c862533ca767ee/flame.go#L82-L84) (including middleware) to be invoked in the same order as they are registered. -By default, the next handler will only be invoked after the previous one in the chain has finished. You may change this behvaior using the `Next` method, which allows you to pause the execution of the current handler and resume after the rest of the chain finished. +By default, the next handler will only be invoked after the previous one in the chain has finished. You may change this behavior using the `Next` method, which allows you to pause the execution of the current handler and resume after the rest of the chain finished. ```go:no-line-numbers package main @@ -197,7 +197,7 @@ There is a family of `Query` methods available at your fingertips, including: All of these methods accept an optional second argument as the default value when the parameter is absent. ::: tip -If you are not happy with the functionality that is provided by the family of `Query` methods, it is always possible to build your own helpers (or middlware) for the URL parameters by accessing the underlying [`url.Values`](https://pkg.go.dev/net/url#Values) directly: +If you are not happy with the functionality that is provided by the family of `Query` methods, it is always possible to build your own helpers (or middleware) for the URL parameters by accessing the underlying [`url.Values`](https://pkg.go.dev/net/url#Values) directly: ```go:no-line-numbers vals := c.Request().URL.Query() @@ -208,7 +208,7 @@ vals := c.Request().URL.Query() No. -The `flamego.Context` is a representation of the request context and should live within the routing layer, where the `context.Context` is a general purpose context and can be propogated to almost anywhere (e.g. database layer). +The `flamego.Context` is a representation of the request context and should live within the routing layer, where the `context.Context` is a general purpose context and can be propagated to almost anywhere (e.g. database layer). You can retrieve the `context.Context` of a request using the following methods: diff --git a/docs/custom-services.md b/docs/custom-services.md index 2f7b5fd..e70c897 100644 --- a/docs/custom-services.md +++ b/docs/custom-services.md @@ -13,7 +13,7 @@ The [core services](core-services.md) from Flamego are great, but they are certa ## Injecting services -The Flame instance is building on top of the [`inject.TypeMapper`](https://pkg.go.dev/github.com/flamego/flamego/inject#TypeMapper) to provide service injections for your handlers. Both [`flamego.Flame`](https://pkg.go.dev/github.com/flamego/flamego#Flame) and [`flamego.Context`](https://pkg.go.dev/github.com/flamego/flamego#Context) have embeded the `inject.TypeMapper` that allow you to inject services at anywhere you want. +The Flame instance is building on top of the [`inject.TypeMapper`](https://pkg.go.dev/github.com/flamego/flamego/inject#TypeMapper) to provide service injections for your handlers. Both [`flamego.Flame`](https://pkg.go.dev/github.com/flamego/flamego#Flame) and [`flamego.Context`](https://pkg.go.dev/github.com/flamego/flamego#Context) have embedded the `inject.TypeMapper` that allow you to inject services at anywhere you want. The `Map` method is used to inject services (aka. map values to their own types), the injected service can be a concrete type ([`*log.Logger`](https://pkg.go.dev/log#Logger)) or an interface ([`io.Writer`](https://pkg.go.dev/io#Writer)): diff --git a/docs/faqs.md b/docs/faqs.md index 703ce10..8442b29 100644 --- a/docs/faqs.md +++ b/docs/faqs.md @@ -114,7 +114,7 @@ func main() { return "The user is Joe" }) - // Pass on all routes under "/user/" to the Flame isntance + // Pass on all routes under "/user/" to the Flame instance http.Handle("/user/", f) if err := http.ListenAndServe("0.0.0.0:2830", nil); err != nil { @@ -154,7 +154,7 @@ func main() { return "The user is Joe" }) - // Pass on all routes under "/user/" to the Flame isntance + // Pass on all routes under "/user/" to the Flame instance m := macaron.New() m.Any("/user/*", f.ServeHTTP) diff --git a/docs/middleware/cache.md b/docs/middleware/cache.md index 264612a..361b471 100644 --- a/docs/middleware/cache.md +++ b/docs/middleware/cache.md @@ -362,4 +362,4 @@ For example: gob.Register(time.Duration(0)) ``` -You only need to regsiter once for the entire lifecyle of your application. +You only need to register once for the entire lifecycle of your application. diff --git a/docs/middleware/session.md b/docs/middleware/session.md index 78867bf..0d22c5d 100644 --- a/docs/middleware/session.md +++ b/docs/middleware/session.md @@ -442,4 +442,4 @@ For example: gob.Register(time.Duration(0)) ``` -You only need to regsiter once for the entire lifecyle of your application. +You only need to register once for the entire lifecycle of your application. diff --git a/docs/starter-guide.md b/docs/starter-guide.md index c8ec789..954a352 100644 --- a/docs/starter-guide.md +++ b/docs/starter-guide.md @@ -52,7 +52,7 @@ $ go run main.go Once you see the last line from your terminal, you're good to go! -You may verify the result by either visiting [http://localhost:2830](http://localhost:2830) ([why 2830?](faqs.md#why-the-default-port-is-2830)) in your browser, or through the folllowing `curl` command: +You may verify the result by either visiting [http://localhost:2830](http://localhost:2830) ([why 2830?](faqs.md#why-the-default-port-is-2830)) in your browser, or through the following `curl` command: ```:no-line-numbers $ curl http://localhost:2830