-
Notifications
You must be signed in to change notification settings - Fork 1
igb/SimpleService
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
GetFunction=fun(Sock, PathString, QueryString, Params, Fragment, Headers, Body)-> gen_tcp:send(Sock, "HTTP/1.1 200 OK\r\nContent-Type: text/plain; charset=UTF-8\r\nConnection: close\r\n\r\nHelo World!\r\n\r\n") end. Functions=[{'GET', GetFunction}]. simpleservice:start(8000, Functions). %% you can also pass a Pid to facilitate dispatches to spawned process or %% other service with simpleservice:start/3 %% Example: simpleservice:start(8000, Functions, MyPid). curl -v 127.0.0.1:8000/hello * About to connect() to 127.0.0.1 port 8000 (#0) * Trying 127.0.0.1... connected * Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0) > GET /hello HTTP/1.1 > User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5 > Host: 127.0.0.1:8000 > Accept: */* > < HTTP/1.1 200 OK < Content-Type: text/plain; charset=UTF-8 < Connection: close < Helo World! * Closing connection #0 curl -v -X DELETE "127.0.0.1:8000/foo/abr?x=y&x=u&bar=foo" * About to connect() to 127.0.0.1 port 8000 (#0) * Trying 127.0.0.1... connected * Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0) > DELETE /foo/abr?x=y&x=u&bar=foo HTTP/1.1 > User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5 > Host: 127.0.0.1:8000 > Accept: */* > < HTTP/1.1 501 Not Implemented < Content-Type: text/plain; charset=UTF-8 < Connection: close < DELETE is not supported by this service. * Closing connection #0
About
Tiny HTTP wrapper/endpoint for deploying simple web services in Erlang.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published