mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
First crack the API
This commit is contained in:
parent
64468cd9ed
commit
b366f8fadc
13 changed files with 139 additions and 24 deletions
28
NzbDrone.Api/Helpers/HttpRequestExtensions.cs
Normal file
28
NzbDrone.Api/Helpers/HttpRequestExtensions.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ServiceStack.Common.Web;
|
||||
using ServiceStack.ServiceHost;
|
||||
|
||||
namespace NzbDrone.Api.Helpers
|
||||
{
|
||||
public static class HttpRequestExtensions
|
||||
{
|
||||
public static string GetApiKey(this IHttpRequest httpReq)
|
||||
{
|
||||
var auth = httpReq.Headers[HttpHeaders.Authorization];
|
||||
if (auth == null) return null;
|
||||
|
||||
var split = auth.Split(' ');
|
||||
|
||||
if (split.Count() != 2)
|
||||
return null;
|
||||
|
||||
if (!split[0].Equals("APIKEY", StringComparison.InvariantCultureIgnoreCase))
|
||||
return null;
|
||||
|
||||
return split[1];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue