Skip to content

Commit 07c5224

Browse files
author
Hiemanshu Sharma
committed
Initial commit with Plug, Iris (Go), Gin (Go), Zewo(Swift)
0 parents  commit 07c5224

17 files changed

+217
-0
lines changed

.Package.toml

Whitespace-only changes.

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj

.swift-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DEVELOPMENT-SNAPSHOT-2016-05-09-a

elixir_test/.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps
9+
10+
# Where 3rd-party dependencies like ExDoc output generated docs.
11+
/doc
12+
13+
# If the VM crashes, it generates a dump, let's ignore it too.
14+
erl_crash.dump
15+
16+
# Also ignore archive artifacts (built via "mix archive.build").
17+
*.ez

elixir_test/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# ElixirTest
2+
3+
**TODO: Add description**
4+
5+
## Installation
6+
7+
If [available in Hex](https://hex.pm/docs/publish), the package can be installed as:
8+
9+
1. Add `elixir_test` to your list of dependencies in `mix.exs`:
10+
11+
```elixir
12+
def deps do
13+
[{:elixir_test, "~> 0.1.0"}]
14+
end
15+
```
16+
17+
2. Ensure `elixir_test` is started before your application:
18+
19+
```elixir
20+
def application do
21+
[applications: [:elixir_test]]
22+
end
23+
```
24+

elixir_test/config/config.exs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This file is responsible for configuring your application
2+
# and its dependencies with the aid of the Mix.Config module.
3+
use Mix.Config
4+
5+
# This configuration is loaded before any dependency and is restricted
6+
# to this project. If another project depends on this project, this
7+
# file won't be loaded nor affect the parent project. For this reason,
8+
# if you want to provide default values for your application for
9+
# 3rd-party users, it should be done in your "mix.exs" file.
10+
11+
# You can configure for your application as:
12+
#
13+
# config :elixir_test, key: :value
14+
#
15+
# And access this configuration in your application as:
16+
#
17+
# Application.get_env(:elixir_test, :key)
18+
#
19+
# Or configure a 3rd-party app:
20+
#
21+
# config :logger, level: :info
22+
#
23+
24+
# It is also possible to import configuration files, relative to this
25+
# directory. For example, you can emulate configuration per environment
26+
# by uncommenting the line below and defining dev.exs, test.exs and such.
27+
# Configuration from the imported file will override the ones defined
28+
# here (which is why it is important to import them last).
29+
#
30+
# import_config "#{Mix.env}.exs"

elixir_test/lib/elixir_test.ex

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
defmodule ElixirTest do
2+
use Application
3+
4+
def start(_type, _args) do
5+
import Supervisor.Spec, warn: false
6+
7+
children = [
8+
worker(ElixirTest.Web, [])
9+
]
10+
11+
opts = [strategy: :one_for_one, name: ElixirTest.Supervisor]
12+
Supervisor.start_link(children, opts)
13+
end
14+
end

elixir_test/lib/elixir_test/web.ex

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
defmodule ElixirTest.Web do
2+
use Plug.Router
3+
require Logger
4+
5+
plug Plug.Logger
6+
plug :match
7+
plug :dispatch
8+
9+
def init(options) do
10+
options
11+
end
12+
13+
def start_link do
14+
{:ok, _} = Plug.Adapters.Cowboy.http ElixirTest.Web, []
15+
end
16+
17+
get "/" do
18+
conn
19+
|> send_resp(200, "Hello, World!")
20+
|> halt
21+
end
22+
end

elixir_test/mix.exs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
defmodule ElixirTest.Mixfile do
2+
use Mix.Project
3+
4+
def project do
5+
[app: :elixir_test,
6+
version: "0.1.0",
7+
elixir: "~> 1.3",
8+
build_embedded: Mix.env == :prod,
9+
start_permanent: Mix.env == :prod,
10+
deps: deps()]
11+
end
12+
13+
# Configuration for the OTP application
14+
#
15+
# Type "mix help compile.app" for more information
16+
def application do
17+
[
18+
applications: [:logger, :cowboy, :plug],
19+
mod: {ElixirTest, []}
20+
]
21+
end
22+
23+
# Dependencies can be Hex packages:
24+
#
25+
# {:mydep, "~> 0.3.0"}
26+
#
27+
# Or git/path repositories:
28+
#
29+
# {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
30+
#
31+
# Type "mix help deps" for more examples and options
32+
defp deps do
33+
[
34+
{:cowboy, "~> 1.0.3"},
35+
{:plug, "~> 1.0"},
36+
]
37+
end
38+
end

elixir_test/mix.lock

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
%{"cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:rebar, :make], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, optional: false]}]},
2+
"cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], []},
3+
"plug": {:hex, :plug, "1.1.6", "8927e4028433fcb859e000b9389ee9c37c80eb28378eeeea31b0273350bf668b", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}]},
4+
"ranch": {:hex, :ranch, "1.2.1", "a6fb992c10f2187b46ffd17ce398ddf8a54f691b81768f9ef5f461ea7e28c762", [:make], []}}

elixir_test/test/elixir_test_test.exs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
defmodule ElixirTestTest do
2+
use ExUnit.Case
3+
doctest ElixirTest
4+
5+
test "the truth" do
6+
assert 1 + 1 == 2
7+
end
8+
end

elixir_test/test/test_helper.exs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ExUnit.start()

go/gin.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import "github.com/gin-gonic/gin"
4+
5+
func main() {
6+
r := gin.Default()
7+
r.GET("/hello", func(c *gin.Context) {
8+
c.JSON(200, gin.H{
9+
"hello": "world",
10+
})
11+
})
12+
r.Run() // listen and server on 0.0.0.0:8080
13+
}

go/iris.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
import (
4+
"github.com/kataras/iris"
5+
)
6+
7+
func main() {
8+
// render JSON
9+
iris.Get("/hello", func(c *iris.Context) {
10+
c.JSON(iris.StatusOK, iris.Map{
11+
"hello": "World!",
12+
})
13+
})
14+
iris.Listen(":8080")
15+
}

zewo/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj

zewo/Package.swift

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import PackageDescription
2+
3+
let package = Package(
4+
name: "zewo",
5+
dependencies: [
6+
.Package(url: "https://github.com/VeniceX/HTTPServer.git", majorVersion: 0, minor: 7),
7+
.Package(url: "https://github.com/Zewo/Router.git", majorVersion: 0, minor: 7),
8+
]
9+
)

zewo/Sources/main.swift

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import HTTPServer
2+
import Router
3+
4+
let app = Router { route in
5+
route.get("/hello/:name") { request in
6+
guard let name = request.pathParameters["name"] else {
7+
return Response(status: .internalServerError)
8+
}
9+
return Response(body: "Hello, \(name)!")
10+
}
11+
}
12+
13+
try Server(app).start()

0 commit comments

Comments
 (0)