Aadya v0.1.0 Aadya.Router View Source

Coap Router Module

Link to this section Summary

Functions

Resposne to Router

  defmodule Hello do
    def hello path do
      case :ets.lookup :resource,path do
        [] ->
          {:not_found, :not_found}
        [{_,data}] ->
          { :created , data }
        end
    end
    def post path,data do
      case :ets.insert(:resource,{path,data}) do
        true ->
          {:ok, data}
        _ ->
          IO.puts "something went worong"
          {:error, error}
      end
    end
    def put path,data do
      case :ets.insert(:resource,{path,data}) do
        true ->
          {:ok, data}
        _ ->
          IO.puts "something went worong"
          {:error, "erroror"}
      end
    end
  end

Link to this section Functions

Link to this macro __using__(options) View Source (macro)

Resposne to Router

  defmodule Hello do
    def hello path do
      case :ets.lookup :resource,path do
        [] ->
          {:not_found, :not_found}
        [{_,data}] ->
          { :created , data }
        end
    end
    def post path,data do
      case :ets.insert(:resource,{path,data}) do
        true ->
          {:ok, data}
        _ ->
          IO.puts "something went worong"
          {:error, error}
      end
    end
    def put path,data do
      case :ets.insert(:resource,{path,data}) do
        true ->
          {:ok, data}
        _ ->
          IO.puts "something went worong"
          {:error, "erroror"}
      end
    end
  end

Resposne Codes:

  (:content) ->: {2, 0}
  (:created) ->: {2, 1}
  (:deleted) ->: {2, 2}
  (:valid) ->: {2, 3}
  (:changed) ->: {2, 4}
  (:continue) ->: {2,31}

  (:bad_request) ->: {4, 0}
  (:unauthorized) ->: {4, 1}
  (:bad_option) ->: {4, 2}
  (:not_found) ->: {4, 4}
  (:method_not_allowed) ->: {4, 5}
  (:not_acceptable) ->: {4, 6}
  (:request_entity_incomplete) ->: {4, 7}
  (:request_entity_incomplete) ->: {4, 8}
  (:precondition_failed) ->: {4, 12}
  (:request_entity_too_large) ->: {4, 13}
  (:unsupported_content_format) ->: {4, 15}

  (:internal_server_error) ->: {5, 0}
  (:not_implemented) ->: {5, 1}
  (:bad_gateway) ->: {5, 2}
  (:service_unavailable) ->: {5, 3}
  (:gateway_timeout) ->: {5, 4}
  (:proxying_not_supported) ->: {5, 5}
Link to this macro delete(path, module, function) View Source (macro)
Link to this macro get(path, module, function) View Source (macro)
Link to this macro post(path, module, function) View Source (macro)
Link to this macro put(path, module, function) View Source (macro)
Link to this macro unobserve(path) View Source (macro)