Skip to content

Commit

Permalink
fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
taicsuzu committed Mar 25, 2017
1 parent 0dea82b commit 33efb35
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Define your API. All API have to take Context and UriParams arguments and return
class WebServer
def index(context : Context, uriParams : UriParams) : Context
# ...Write your logic here...
return context
return context
end
end
```
Expand All @@ -48,40 +48,40 @@ end
```

To activate the routes, pass a context from `HTTP::Server` to routing like
```
```crystal
class WebServer
def run
server = HTTP::Server.new(3000) do |context|
routing(context) # Pass context to `routing`
end
routing(context) # Pass context to `routing`
end
server.listen
server.listen
end
end
```

Finally, run your server.
```
```crystal
web_server = WebServer.new
web_server.run
```

UriParams is a Hash(String, String) that is used when you define a path including parameters such as `"/user/:id"`(`:id` is a parameters). Here is an example.
```
```crystal
class WebServer
def initialize
get "/user/:id"
end
def user_id(context : Context, uriParams : UriParams) : Context
id = uriParams["id"] # You can refer the :id like this.
... Your logics here
return context
... Your logics here
return context
end
end
```

See `sample/` for details.
See [sample](https://github.com/tbrand/route.cr/blob/master/example/sample.cr) for details.

## Contributing

Expand Down

0 comments on commit 33efb35

Please sign in to comment.