Skip to content
gleam-langPublic

About

🤠 A Gleam HTTP service adapter for the Cowboy web server

Topics

Resources

Code of conduct

Security policy

Stars

76 stars

Watchers

1 watching

Forks

Latest commit

 

History

73 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gleam Cowboy! 🤠

A Gleam HTTP service adapter for the Cowboy web server.

You may want to consider using the Mist web server instead as it has better performance, features type safe websockets, and is written entirely in Gleam. It is also supported by the Wisp web framework.

Installation

gleam add gleam_cowboy
import gleam/erlang/process
import gleam/http/cowboy
import gleam/http/response.{type Response}
import gleam/http/request.{type Request}
import gleam/bytes_tree.{type BytesTree}

// Define a HTTP service
//
pub fn my_service(request: Request(t)) -> Response(BytesTree) {
  let body = bytes_tree.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)
  process.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

Topics

Resources

Code of conduct

Security policy

Stars

76 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages