• Stars
    star
    304
  • Rank 137,274 (Top 3 %)
  • Language
    Elixir
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HTTP web server and client, supports http1 and http2

Ace

HTTP web server and client, supports http1 and http2

Hex pm Build Status License

See Raxx.Kit for a project generator that helps you set up a web project based on Raxx/Ace.

Get started

Hello, World!

defmodule MyApp do
  use Ace.HTTP.Service, port: 8080, cleartext: true
  use Raxx.SimpleServer

  @impl Raxx.SimpleServer
  def handle_request(%{method: :GET, path: []}, %{greeting: greeting}) do
    response(:ok)
    |> set_header("content-type", "text/plain")
    |> set_body("#{greeting}, World!")
  end
end

The arguments given to use Ace.HTTP.Service are default values when starting the service.

Start the service

config = %{greeting: "Hello"}

MyApp.start_link(config, port: 1234)

Here the default port value has been overridden at startup

Raxx

Ace implements the Raxx HTTP interface. This allows applications to be built with any components from the Raxx ecosystem.

Raxx has tooling for streaming, server-push, routing, api documentation and more. See documentation for details.

The correct version of raxx is included with ace, raxx does not need to be added as a dependency.

TLS/SSL

If a service is started without the cleartext it will start using TLS. This requires a certificate and key.

config = %{greeting: "Hello"}
options = [port: 8443, certfile: "path/to/certificate", keyfile: "path/to/key"]

MyApp.start_link(application, options)

TLS is required to serve content via HTTP/2.

Supervising services

The normal way to run services is as part of a projects supervision tree. When starting a new project use the --sup flag.

mix new my_app --sup

Add the services to be supervised in the application file lib/my_app/application.ex.

defmodule MyApp.Application do
  @moduledoc false

  use Application

  def start(_type, _args) do
    import Supervisor.Spec, warn: false

    children = [
      {MyApp, [%{greeting: "Hello"}]}
    ]

    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)
  end
end

Start project using iex -S mix and visit http://localhost:8080.

Testing

mix test --include ci:true

Will run h2spec as one of the tests.

If the h2spec is not specified in the environment variable $H2SPEC_PATH or on the $PATH, it will be downloaded into test/support/h2spec/ and executed.

Alternative HTTP servers

Other servers you can use for Elixir/erlang applications are Cowboy and Elli.

Of the three Cowboy is the most widely used. Both Elli and Cowboy are written in erlang, Ace is written in Elixir.

Elixir HTTP Benchmark - Ace vs Cowboy

More Repositories

1

OK

Elegant error/exception handling in Elixir, with result monads.
Elixir
599
star
2

raxx

Interface for HTTP webservers, frameworks and clients
Elixir
401
star
3

elixir-on-docker

Quickly get started developing clustered Elixir applications for cloud environments.
Elixir
172
star
4

eyg-lang

Experiments in building "better" languages and tools; for some measure of better.
Gleam
151
star
5

raxx_kit

Get started with Raxx + Elixir
HTML
122
star
6

pachyderm

Virtual actors for elixir
Elixir
103
star
7

gen_browser

Transparent bi-directional communication for clients, servers and more
Elixir
68
star
8

plinth

node and browser bindings for gleam
Gleam
56
star
9

watercooler

Building a distributed chatroom with Raxx.Kit
Elixir
25
star
10

server_sent_event.ex

Push updates to Web clients over HTTP or using dedicated server-push protocol
Elixir
20
star
11

awesome-eco

Resources and Prodjects addressing human ecological impact.
12
star
12

vulcanize

Form objects to coerce user input using your value objects
Ruby
10
star
13

AllSystems

Simple Ruby usecases/interactors/service-object to encapsulate business logic
Ruby
10
star
14

typetanic

A few hygenicly namespaced domain objects.
Ruby
6
star
15

rollup-karma-jasmine-example

Calculator project that bundles es6-modules with Rollup. Tests use Jasmine and are run in the browser with Karma
JavaScript
6
star
16

me

All about me
HTML
5
star
17

ace-raxx-clustering-example

An example of how to setup a multi node web service in elixir
Elixir
5
star
18

intention.js

Pure implementation of the JavaScript fetch API exposing an analogue to the promise API.
JavaScript
5
star
19

basic_authentication

Submit and verify client credentials using the 'Basic' HTTP authentication scheme.
Elixir
5
star
20

CORS

Check Cross Origin Request Security headers.
Elixir
4
star
21

comms

Explicit message passing for improved reasoning about actor systems
Elixir
4
star
22

raxx_static

Raxx middleware for serving static content.
Elixir
4
star
23

gleamtours

Tours through various topics in Gleam.
Gleam
4
star
24

greetings-ace-elixir-example

Simple greetings application to showcase developing web services with Ace
Elixir
3
star
25

cookie.ex

Elixir
3
star
26

eex_html

Extension to Embedded Elixir (EEx), that allows content to be safely embedded into HTML.
Elixir
3
star
27

num

Because floats were never really numbers
Elixir
3
star
28

no-code

Notes on no-code programming
3
star
29

raxx_api_blueprint

Route requests based on an API Blueprint
Elixir
3
star
30

carbide.js

Minimal immutable objects in JavaScript
JavaScript
3
star
31

greetings-ace-raxx-erlang-example

Simple greetings application to showcase developing web services with Ace and Raxx in erlang
Erlang
3
star
32

gleamweekly

Gleam is so hot right now. There is so much happening in our wonderful and growing community that you wouldn't want to miss.
HTML
3
star
33

raxx.rs

How to web dev with Rust
Rust
2
star
34

git_status

Compile time status of GIT repository for source code.
Elixir
2
star
35

level

A spirit level for your device. No download required
JavaScript
2
star
36

echo-server.hs

TCP echo server written in Haskell.
Haskell
2
star
37

svg-crop

Output PNG's at a variety of size's and aspect ratios from a single SVG source.
JavaScript
2
star
38

phonegap-vector-assets

Create multiple resolution assets for phonegap applications directly from config.xml
JavaScript
2
star
39

phonegap-icon-set

An example project to generate multiple icons for phonegap
JavaScript
1
star
40

Almighty

Environment recreation and dotfile plus
Shell
1
star
41

IOC-example.js

Inversion of control architecture for JavaScript applications
JavaScript
1
star
42

eyg

Explicit concurrency for intelligible parallel programing.
Rust
1
star
43

cut-the-mustard

Checking your JS environment is up to scratch
JavaScript
1
star
44

svg_agile

SVG manipulation on with touch or mouse
JavaScript
1
star
45

phonegap-screenshot-example

Generating webview screenshots for use in app stores.
JavaScript
1
star
46

lob

Demonstrating realtime connection between web browsers. Powered by ably.io. Created by Workshop14.io
JavaScript
1
star
47

Curriculum-Vitae

Curriculum Vite for Peter Saxton
TeX
1
star
48

HammerHead

A minimal JavaScript utility to help view SVG's on webpages
JavaScript
1
star
49

bbox

Find bounding box dimensions either within or surrounding arbitrary containers
JavaScript
1
star
50

just-job

Just Job is a todo list built from the ground up using the principles of Domain Driven Design(DDD)
Ruby
1
star