feat: add example
This commit is contained in:
parent
674e2dbca3
commit
489d2bb344
|
@ -0,0 +1,15 @@
|
||||||
|
#include <httpserver.hpp>
|
||||||
|
using namespace httpserver;
|
||||||
|
class hello_world_resource : public http_resource {
|
||||||
|
public:
|
||||||
|
std::shared_ptr<http_response> render(const http_request&) {
|
||||||
|
return std::shared_ptr<http_response>(new string_response("Hello, World!"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
webserver ws = create_webserver(8080);
|
||||||
|
hello_world_resource hwr;
|
||||||
|
ws.register_resource("/hello", &hwr);
|
||||||
|
ws.start(true);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#target: dependency_1 dependency_2 dependency_3 ...
|
||||||
|
# command
|
||||||
|
#
|
||||||
|
RM = /bin/rm -f
|
||||||
|
OBJ = main.o
|
||||||
|
EXE = main
|
||||||
|
CC = /usr/bin/g++
|
||||||
|
CXXFLAGS = -Wall
|
||||||
|
LDFLAGS = -L/usr/local/lib -lhttpserver
|
||||||
|
#
|
||||||
|
all: $(EXE)
|
||||||
|
#
|
||||||
|
$(EXE): $(OBJ)
|
||||||
|
$(CC) $(CXXFLAGS) $(LDFLAGS) $(OBJ) -o $(EXE)
|
||||||
|
#
|
||||||
|
main.o: main.cpp
|
||||||
|
$(CC) -c main.cpp -o main.o
|
||||||
|
#
|
||||||
|
clean:
|
||||||
|
$(RM) $(OBJ) $(EXE) *~
|
Loading…
Reference in New Issue