Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🪁 A simple, type-safe http server for PureScript

License

NotificationsYou must be signed in to change notification settings

sigma-andex/purescript-httpurple

Repository files navigation

Licensepurescript-httpurple on Pursuit

A functional http server with a focus on type-safety and making the common case easy.

Note: If you are looking for a http client, check outpurescript-fetch

Note: This project was originally forked from the amazingHTTPure http server framework, but has since deviated quite a bit. If you are coming from HTTPure you might want to have a look at thedifferences to HTTPure.

ToC

  1. Features
  2. Installation
  3. Quick start
  4. Documenation
  5. Examples
  6. Testing
  7. License

Features

  • λ fp-style http server & request handlers
  • 🛣 Powerful & type-safe routing dsl
  • 🕵🏻‍♂️ Easy json parsing and data validation
  • 🥪 Supports Node/Express middlewares
  • 📜 Extensive documentation & examples

Installation

spago install httpurple

Quick start

moduleMainwhereimportPreludehiding ((/))importHTTPurpledataRoute =HelloStringderive instanceGenericRoute_route::RouteDuplex'Routeroute = mkRoute  {"Hello":"hello" / segment  }main::ServerMmain =  serve { port:8080 } { route, router }  where  router { route:Hello name } = ok $"hello" <> name

then start the server

➜ spago run           Src   Lib   AllWarnings   0     0     0  Errors     0     0     0  [info] Build succeeded.HTTPurple 🪁 up and running on http://0.0.0.0:8080

query your server, e.g. usinghttpie

➜ http http://localhost:8080/hello/🗺  HTTP/1.1 200 OKConnection: keep-aliveContent-Length: 10Date: Sun, 22 May 2022 16:50:52 GMTKeep-Alive: timeout=5hello 🗺

Documentation

See thedocs folder for the in-depth guides.

  • Basics - Basic introduction to HTTPurple 🪁
  • Routing - Explanation of the routing dsl
  • Requests - Guide to request handling
  • Response - Guide to response handling
  • Middleware - Guide to HTTPurple and Node.js middlewares
  • Differences - A detailed description of the differences to HTTPure

Examples

HTTPurple ships with a number ofexamples. To run an example,in the project root, run:

spago -x test.dhall run --main Examples.<Example Name>.Main

Each example's startup banner will include information on routes available onthe example server.

Testing

To run the test suite, in the project root run:

spago -x test.dhalltest

License

This is a fork ofHTTPure, which is licensed under MIT. See theoriginal license. This work is similarly licensed underMIT.

About

🪁 A simple, type-safe http server for PureScript

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors19


[8]ページ先頭

©2009-2025 Movatter.jp