Skip to content

Commit

Permalink
alpaca: Initializing the project
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Santos committed Sep 27, 2023
0 parents commit e1b29f6
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_build
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Alpaca http library

Alpaca is a simple and easy to use http library for OCaml.

30 changes: 30 additions & 0 deletions alpaca.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "Http library"
description: "Http library"
maintainer: ["ProgramingIsTheFuture"]
authors: ["ProgramingIsTheFuture"]
homepage: "https://github.com/ProgramingIsTheFuture/alpaca"
bug-reports: "https://github.com/ProgramingIsTheFuture/alpaca/issues"
depends: [
"ocaml"
"dune" {>= "3.10"}
"eio_main"
"eio"
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/ProgramingIsTheFuture/alpaca.git"
25 changes: 25 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(lang dune 3.10)

(name alpaca)

(generate_opam_files true)

(source
(github ProgramingIsTheFuture/alpaca))

(authors "ProgramingIsTheFuture")

(maintainers "ProgramingIsTheFuture")

(package
(name alpaca)
(synopsis "Http library")
(description "Http library")
(depends ocaml dune eio_main eio))

(package
(name test_alpaca)
(allow_empty)
(synopsis "Test http library")
(description "Test http library")
(depends ocaml dune alpaca))
15 changes: 15 additions & 0 deletions src/alpaca.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
type request
type response
type handler = request -> response
type methods = [ `Get | `Post | `Patch | `Delete | `Put ]
type route_configs = { methods : methods list }

type configs = {
port : int;
routes : (string * handler * route_configs option) list;
}

let route ?(methods = [ `Get ]) path handler = (path, handler, { methods })
let new_app ?(port = 8000) () = { port; routes = [] }
let router lroutes app = { app with routes = lroutes @ app.routes }
let run _configs = Eio_main.run (fun _env -> assert false)
4 changes: 4 additions & 0 deletions src/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(library
(public_name alpaca)
(name alpaca)
(libraries eio_main eio))
3 changes: 3 additions & 0 deletions test/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(executable
(name test_alpaca)
(libraries alpaca))
3 changes: 3 additions & 0 deletions test/test_alpaca.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
open Alpaca

let () = new_app () |> run
29 changes: 29 additions & 0 deletions test_alpaca.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
synopsis: "Test http library"
description: "Test http library"
maintainer: ["ProgramingIsTheFuture"]
authors: ["ProgramingIsTheFuture"]
homepage: "https://github.com/ProgramingIsTheFuture/alpaca"
bug-reports: "https://github.com/ProgramingIsTheFuture/alpaca/issues"
depends: [
"ocaml"
"dune" {>= "3.10"}
"alpaca"
"odoc" {with-doc}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
dev-repo: "git+https://github.com/ProgramingIsTheFuture/alpaca.git"

0 comments on commit e1b29f6

Please sign in to comment.