tomkuijsten / restup

Webserver for universal windows platform (UWP) apps
MIT License
114 stars 48 forks source link

Can't call the MutableHttpServerRequest() constructor ... #118

Closed alwendt4 closed 7 years ago

alwendt4 commented 7 years ago

Having a really, really hard time returning responses in XML format. Basically, I want to implement your headless demo, with a response in XML NOT JSON.

Spent hours and hours and hour looking at your stuff ... guessed myself into using the RestRouteHandlerTest.Happy.cs as a sample, but when I execute:

    private MutableHttpServerRequest _basicGETAcceptXML = new MutableHttpServerRequest()
    {
        Method = HttpMethod.GET,
        Uri = new Uri("/users/2", UriKind.RelativeOrAbsolute),
        AcceptMediaTypes = new[] { "application/xml" },
        IsComplete = true
    };

... it tells me that the MutableHttpServerRequest doesn't have a constructor.

Basically, my headless demo has a Run() method like this ... public async void Run(IBackgroundTaskInstance taskInstance) { _deferral = taskInstance.GetDeferral(); RestRouteHandler restRouteHandler = new RestRouteHandler(); restRouteHandler.RegisterController();

        var configuration = new HttpServerConfiguration()
          .ListenOnPort(8800)
          .RegisterRoute("api", restRouteHandler)
          .EnableCors();

        var httpServer = new HttpServer(configuration);
        _httpServer = httpServer;

        await httpServer.StartServerAsync();

        taskInstance.Canceled += TaskInstance_Canceled;
    }

How the HECK do I set the response content-type?!!!!

I'm using PostMan as my RESTful client. It's receiving my request, and returning the response in JSON format. I'm stumped.

I've been trying to do this for weeks!!!!

No really good samples. Help!!!!

alwendt4 commented 7 years ago

I figured it out. Simply send requests with the "Accept" header = "application/xml". Please close issue. Sorry for my lack of knowledge.

Jark commented 7 years ago

Hey @alwendt4,

Apologise for the late response, I'm glad you figured it out. I'll take a look at your other issue now.

Cheers,

Jark