alxchoy

alxchoy

How to create local server

Hi everybody,

I’m new in this programming language, my question is about create a simple http server.
For example in golang or nodeJs, I only need use owner http modules but in elixir I need cowboy? Plug? Potion?. I was reading about GenServer i don’t know if this is the answer. Thank for help me.

Sry but I’m not native speaker.

Most Liked

hauleth

hauleth

There is built in module httpd which provides very, very simple HTTP server. Think of it like Ruby’s WEBrick or Python’s http.server modules. This is very, very simple server that is not suitable for “real world” usage. On the other hand Cowboy, Raxx, Elli and others are much more powerful implementations with a lot of different features that can handle heavy loads, do pooling, proper error handling, etc.

Of course you can implement your own server on top of gen_tcp (with or without ssl module), but it would be NIH syndrome (unless you know what you are doing).

But if you want something that is super simple - plug and play - server, then you can use raw Plug directly. RN it has support only for Cowboy, but it is pretty solid implementation that will probably fit your use case in 100%. But nothing prevents you from using Cowboy directly.

kokolegorille

kokolegorille

The usual way to build http server is to use Phoenix, it uses cowboy under the hood.

But there are alternatives, like Raxx… or go bare with gen_tcp

pdgonzalez872

pdgonzalez872

Welcome @alxchoy!

Here is a great intro to Plug: https://elixirschool.com/en/lessons/specifics/plug/, a way of creating a minimal webserver.

For anything else, I’d strongly suggest looking at Phoenix: https://hexdocs.pm/phoenix/up_and_running.html#content

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement