Jump to content

Wiki issue: ResultFactory.ThrowError (?)


DSinapellido

Recommended Posts

DSinapellido

I want to throw a 401 error whenever a user is not authenticated. For this, I included IHasResultFactory on my ServerEndpoint class

    class ServerEndpoint : IService, IHasResultFactory
    {
        public IHttpResultFactory ResultFactory { get; set; }
        public IRequest Request { get; set; }

        private readonly SimklApi _api;
        private readonly ILogger _logger;
        private readonly IJsonSerializer _json;

        public ServerEndpoint(SimklApi api, ILogger logger, IJsonSerializer json)
        {
            _api = api;
            _logger = logger;
            _json = json;
        }

The thing is, I can't find the ThrowError function mentioned on https://github.com/MediaBrowser/Emby/wiki/Creating-Api-Endpoints

I can't even find it on Github https://github.com/MediaBrowser/Emby.Common/blob/master/MediaBrowser.Controller/Net/IHttpResultFactory.cs

 

How should, or how I can throw an http error if someone uses my Server Api Endpoint?

Link to comment
Share on other sites

DSinapellido

You can instead just add the [Authenticated] attribute to your ServerEndpoint class.

But, Is there any way to use the ThrowError function or to return another HTTP Status code besides 200/500?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...