Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Jan 29, 2022
1 parent 5d162f6 commit e41de3d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@ Types and functions for HTTP clients and servers!
## HTTP Service Example

```rust
import gleam/http
import gleam/http/elli
import gleam/http.{Request, Response}
import gleam/http/response.{Response}
import gleam/http/request.{Request}
import gleam/bit_builder.{BitBuilder}
import gleam/erlang

// Define a HTTP service
//
pub fn my_service(req: Request(BitString)) -> Response(BitBuilder) {
pub fn my_service(request: Request(t)) -> Response(BitBuilder) {
let body = bit_builder.from_string("Hello, world!")

http.response(200)
|> http.prepend_resp_header("made-with", "Gleam")
|> http.set_resp_body(body)
response.new(200)
|> response.prepend_header("made-with", "Gleam")
|> response.set_body(body)
}

// Start it on port 3000 using the Elli web server
//
pub fn start() {
pub fn main() {
elli.start(my_service, on_port: 3000)
erlang.sleep_forever()
}
```

Expand Down

0 comments on commit e41de3d

Please sign in to comment.