> Is there a full user-auth stack integrated with Wt?
Wt::Auth (authentication, not authorization), which can be used in
conjunction with Wt::Dbo (databases)

http://www.webtoolkit.eu/wt/doc/reference/html/group__auth.html
http://www.webtoolkit.eu/wt/doc/reference/html/group__dbo.html

Introduction to Wt::Auth:
http://www.webtoolkit.eu/wt/doc/tutorial/auth.html

> E.g.: can I setup routes and whatnot based on which role the user who
> attempts to access the API is?
Wt::Auth is used to be sure, that user is actually the person, which
he is claims to be (authentication). To implement Roles
(authorization, e.g. user permissions to do smth), you should
implement your own class and connect it to Wt::Auth  (see AuthInfo
class).

http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1Auth_1_1Dbo_1_1AuthInfo.html

>
> On Tue, May 29, 2012 at 6:37 PM, Nagaev Boris <[email protected]> wrote:
>> Hello!
>>
>> I changed your code to work as expected:
>>
>> 1. remove #if macros
>> 2. remove call of Wt::WRun, which used to prevent the program to enter
>> try-catch.
>> 3. remove RestApplication class (which is not needed for this example)
>> 4. add beingDeleted(); to ~RestGetHello() (as as stated in documentation)
>>
>> On Tue, May 29, 2012 at 11:02 AM, Plug Gulp <[email protected]> wrote:
>>> Hi,
>>>
>>> Please forgive my lack of knowledge on both web-development and Wt. I
>>> am an embedded software engineer and new to both Wt and web
>>> development. I am trying to learn Wt. Since last couple of days I have
>>> been trying to understand how to implement RESTful API using Wt. But
>>> with no success.
>>>
>>> How do I implement a RESTful service using Wt? Say, I want to
>>> implement a simple RESTful API:
>>>
>>> http://www.example.com/hello
>>>
>>> This API should return the data "Hello World!". How do I achieve this using 
>>> Wt?
>>>
>>> I read on the mailing list that WResource is used to implement RESTful
>>> service in Wt. So I wrote the following code to implement the above
>>> API:
>>>
>>> ////////////////////////////////////////
>>>
>>> #include <Wt/WServer>
>>> #include <Wt/WResource>
>>> #include <Wt/Http/Response>
>>>
>>> using namespace Wt;
>>>
>>> class RestGetHello : public Wt::WResource
>>> {
>>>    public:
>>>        virtual ~RestGetHello(){}
>>>
>>>    protected:
>>>        virtual void handleRequest(const Wt::Http::Request &request,
>>> Wt::Http::Response &response)
>>>        {
>>>            response.out() << "Hello World!\n";
>>>        }
>>> };
>>>
>>> #if defined(WITH_WAPP)
>>> class RestApplication : public WApplication
>>> {
>>>    public:
>>>        RestApplication(const WEnvironment& env)
>>>            : WApplication(env)
>>>        {
>>>            WServer::instance()->addResource(&getHello, "/hello");
>>>        }
>>>
>>>    private:
>>>        RestGetHello getHello;
>>> };
>>>
>>> WApplication *createApplication(const WEnvironment& env)
>>> {
>>>    return new RestApplication(env);
>>> }
>>> #endif
>>>
>>> int main(int argc, char **argv)
>>> {
>>> #if defined(WITH_WAPP)
>>>    return Wt::WRun(argc, argv, &createApplication);
>>> #else
>>>    try {
>>>        WServer server(argv[0]);
>>>
>>>        server.setServerConfiguration(argc, argv);
>>>
>>>        RestGetHello getHello;
>>>
>>>        server.addResource(&getHello, "/hello");
>>>
>>>        if (server.start()) {
>>>            WServer::waitForShutdown();
>>>            server.stop();
>>>        }
>>>    } catch (WServer::Exception& e) {
>>>        std::cerr << e.what() << std::endl;
>>>    } catch (std::exception &e) {
>>>        std::cerr << "exception: " << e.what() << std::endl;
>>>    }
>>> #endif
>>> }
>>>
>>> ///////////////////////////////////////
>>>
>>> I am using the following command to access this API:
>>>
>>> curl http://www.example.com/hello
>>>
>>> But all that I get is the content of an HTML page generated by Wt. I
>>> am attaching with this e-mail the output of the above command. Please
>>> could you provide example on how to implement RESTful service using
>>> Wt?
>>>
>>> Thanks and regards,
>>>
>>> ~Plug
>>>
>>> ------------------------------------------------------------------------------
>>> Live Security Virtual Conference
>>> Exclusive live event will cover all the ways today's security and
>>> threat landscape has changed and how IT managers can respond. Discussions
>>> will include endpoint security, mobile security and the latest in malware
>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>> _______________________________________________
>>> witty-interest mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/witty-interest
>>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> witty-interest mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/witty-interest
>>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to