Giter Site home page Giter Site logo

crowdhailer / raxx Goto Github PK

View Code? Open in Web Editor NEW
400.0 13.0 29.0 840 KB

Interface for HTTP webservers, frameworks and clients

Home Page: https://hexdocs.pm/raxx

License: Apache License 2.0

Elixir 99.86% HTML 0.14%
umbrella rack elixir-webservers elixir web-application-framework cowboy ace web backend framework

raxx's People

Contributors

arcz avatar charlesokwuagwu avatar chx avatar crowdhailer avatar girishramnani avatar ktec avatar lasseebert avatar nietaki avatar sheeldotme avatar varnerac avatar wayann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raxx's Issues

Add middleware Raxx.Logger

This should be started in a new repo and linked from the extensions section of this repo.
The hex project should be raxx_logger

Add documentation to raxx_cowboy

  • Add documentation to README
  • Ensue Docs available on hex
  • Improve hello_cowboy example, ideally add to supervision tree #31
  • Link from top level README

Raise error for incomplete response without new server state

If any callback returns a response with body set to true an error should be raised. This is because the response is incomplete.

e.g.

defmodule MyServer do
use Raxx.Server

def handle_request(request, state) do
  response = Raxx.response(:ok)
  |> Raxx.set_body(true)
end
end

This example should raise an error
the correct return value is {response, new_state}

Add @impl

All examples should have @impl Raxx.Server used correctly through out the project

rename helper functions

Raxx.ServerSentEvents -> Rack.ServerSentEvents.Handler

Raxx.Handler -> Raxx.{Basic/Core/Request}.Handler

Error Handlers

Have an extensible method for handling errors within the main callbacks.

Do we need different error handlers for different call backs. Or can we just have a return value of resolved/not_resolved

URI query decoding.

I am unclear why elixirs URL library does not support lists when encoding and decoding query strings

URI.decode_query("foo[]=1&foo[]=2")
# %{"foo[]" => "2"}
# But I would expect %{"foo" => ["1", "2"]} 

This is obviously a deliberate choice as in the docs is this quote

Keys and values can be any term that implements the String.Chars protocol, except lists which are explicitly forbidden.

elixir-lang/elixir#2876 Suggests just using plug but I will be instead copy and pasting as raxx cannot depend on plug.

setting up raxx for ssl

Thanks for this simple web server library.

Please can you give an example of how to setup raxx as a secure server, i.e. with ssl.
I have looked at your Elli and Cowboy adaptors, I cannot find where you handle https.

add protocol field to request

destructing of the Host field gives host and port but also protocol and possibly authority. Though I think that authority is not part of the updated rfc.

Use logger

Use logger not IO.inspect on adapter.

separate projects for hex

so far

  • core (raxx)
  • server_sent_events (SSE)
  • chunked (possibly core)
  • test (might just be methods eg Raxx.get
  • error handler and debug page
  • static
  • session
  • validate to check server implementations
  • ace_http (maybe move ace itself as part of the project)

have some master test file for integrations

be able to make a stack of middleware

I think there must be some great macro stuff possible here to reduce runtime lookups

defmodule MyApp do
  use Raxx.Stack

  stack Raxx.Csrf
  stack Raxx.Session, secret: "top secret"
  stack Raxx.GZip
  stack Raxx.Time
  stack Raxx.WhoAmI, server_name: "my name"
  stack Raxx.ContentLength
  stack Raxx.Head
  stack Raxx.Scrub, (redirect or rewrite)
  
  mount "/assets", AssetsController
  service "/accounts", "accounts.app.consul"
end

Streaming

  • long poll

Long poll should just await within function

  • chunked responses
  • chunked requests

https://24ways.org/2016/http2-server-push-and-service-workers/
https://github.com/phoenixframework/phoenix/blob/v1.2.3/lib/phoenix/transports/long_poll.ex#L1

[state, [{target, message]

%Response{state: :completed, promises: []}
middleware to fetch promises from response links

(server-process) -> (handler-process)
kill handler process after replying.
Good for HTTP2

@expect-continue true
def handle_request(r, c) do
   body = body(r) # memoised
   
   {{__MODULE__, c}, [%Response{body: nil}] # chunked
   {{__MODULE__, c}, []} # longpoll
   {nil, [%Response{body: nil}, promise("/favicon.ico")] # with server push
end

with mailbox monad

def handle_request(r, c) do
  reply(response)
  promise("favicon.ico")
end

def handle_request(r, c) do
  upgrade(__MODULE__, :awaiting)
end

def handle_info(message) do
  reply(response)
end
defmodule Ping.Ready do
  receive config do
    Request(path: ["event", id]) ->
      send(MyApp.PubSub, {self, id})
      send(:timer, 10_000)
      Ping.Awaiting, config
  end
end
defmodule Ping.Awaiting do
  receive config do
    PubSub.update(contents) ->
      send(MyApp.PubSub, {self, id})
      reply(ok("content"))
      Raxx.Completed # could call a close state here
  end
end

Add type specs and dialyzer

Add dialyxir to this project and typespecs to all public functions. The benefits of this are improved documentation as well as an extra layer of checks.

Running dialyzer should become part of the travis test action.

Retire http_status

This is a refactoring issue.

The functionality in http_status should be contained with in the core raxx project. there is no need to have it separate. Also a reason phrase is not part of the HTTP/2 specification.

The function for generating a response start line should also not add a newline character.

The http_status package should be retired on hex.

multi line server sent events

Should be able to send data content with newline characters in it.

Best to testby property testing encode/decode.

Fail build if code is not formatted

This will have to wait until the new year when elixir 1.6 is released. The CI tests should fail if running the formatter would result in a change to the code.

Not sure if such a mix task even exists, but I think it would be good. It would however mean that raxx required 1.6 to work.

use

mix format --check-formatted mix.exs "{lib,test}/**/*.{ex,exs}"

pipe get_content through stack of parsers

copy from plug.

also use the pattern

{buffer, partial}

Can be a middleware layer.

parsing as a stream to go with other middleware stuff. return a list so buffer can contain many parts

Implement headers

headers should be an extensible concept.

Consider having a module for each header eg Raxx.ContentType then other libraries can just implement Raxx.XMyHeader

  • Should we implement a behaviour module for a generic header?

core headers

virtual hosting and the mount field

Host header

All information in the host header is duplicated in other parts the request struct.
The Host header is always required.

Therefore should the host header be deleted from this list of headers?
It should never be relied on and users building request might add a host field but not a host header

Virtual host

Can the Host header have a path in the URL?

Raxx.Request.host + Raxx.Request.mount = virtual host

Router.host instead of Router.mount

In HTTP/2 can the authority header have a path component

Debugger in dev mode

Take the better errors implementation in plug and port to raxx. Would be nice if can be first example of pluggable error handler. #8

Raxx summary function

for logging really.

maybe called inspect

get "/path" (Host: example.com) (Cookie: foo=bar)

Version 1.0

List of decisions to be made before releasing 1.0

  • Is handle_headers a confusing name for a callback? I think perhaps the following might be clearer
    • handle_head/2
    • handle_body/2
    • handle_tail/2
    • handle_info/2
  • Deprecate named header modules, Raxx.Server and Raxx.TransferEncoding
  • ?? Make it a requirement to always have a tail Raxx.Fragment does not need end_stream attribute
  • ?? Rename Raxx.Fragment to Raxx.Body
  • ?? Rename Raxx.Server to Raxx.Spec
  • Look to increase places used.
    • Publish Apple Push Notification Client using Ace and Raxx
    • GRPC implementation with GRPC.Request subset of Raxx.Request
    • GraphQL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.