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

Fix typos #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/core-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -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.

Expand Down
6 changes: 3 additions & 3 deletions docs/core-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion docs/custom-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)):

Expand Down
4 changes: 2 additions & 2 deletions docs/faqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion docs/middleware/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion docs/middleware/session.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion docs/starter-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down