Skip to content
forked from gleam-lang/cowboy

🤠 A Gleam HTTP service adapter for the Cowboy web server

License

Notifications You must be signed in to change notification settings

vstreame/cowboy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gleam Cowboy! 🤠

A Gleam HTTP service adapter for the Cowboy web server.

import gleam/erlang
import gleam/http/cowboy
import gleam/http/response.{Response}
import gleam/http/request.{Request}
import gleam/bit_builder.{BitBuilder}

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

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

// Start it on port 3000!
//
pub fn main() {
  cowboy.start(my_service, on_port: 3000)
  erlang.sleep_forever()
}

Limitations

Cowboy does not support duplicate HTTP headers so any duplicates specified by the Gleam HTTP service will not be sent to the client.

About

🤠 A Gleam HTTP service adapter for the Cowboy web server

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Gleam 80.1%
  • Erlang 19.9%