Jason La
Jason La

Reputation: 1081

Return simple raw string in ServiceStack (.NET)

For our internal monitoring, our dev ops team asked us to provide a simple endpoint for the bot to hit. Something like: www.domain.com/monitor/check

If everything is fine, it should return a raw string, something like "GoodToGo"

We have an app currently using ServiceStack and it works fine, but I'm having trouble adding this simple endpoint. Any help would be appreciated. This is what I have, and it's having trouble finding the route for my "service."

public class InternalService : Service
    {
        public class EmptyRequest {} 

        [Route("/monitor/check", "")]
        public object Get(EmptyRequest request)
        {
            return "GoodToGo";
        }
    }

Upvotes: 1

Views: 188

Answers (1)

mythz
mythz

Reputation: 143319

The [Route] attribute should be on the Request DTO, i.e:

[Route("/monitor/check")]
public class EmptyRequest : IReturn<string> {} 

public class InternalService : Service
{
    public object Get(EmptyRequest request)
    {
        return "GoodToGo";
    }
}

Upvotes: 4

Related Questions