Skip to content

🤠 A Gleam HTTP service adapter for the Cowboy web server

License

Notifications You must be signed in to change notification settings

midas-framework/cowboy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gleam Cowboy! 🤠

A Gleam HTTP service adapter for the Cowboy web server.

import gleam/http/cowboy
import gleam/http.{Request, Response}
import gleam/bit_builder.{BitBuilder}

// Define a HTTP service
//
pub fn my_service(req: Request(BitString)) -> 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)
}

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

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

  • Rust 52.5%
  • Erlang 47.5%