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: Up and Running — Phoenix v1.8.8

Where Next?

Popular in Questions Top

chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31307 143
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
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
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
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

We're in Beta

About us Mission Statement