samedi 27 décembre 2014

Which design pattern for my proxy Rule

I have a proxy HttpHandler that gets a url from user as a querystring parameter like following.



public class MagicProxy : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string requestUrl = HttpUtility.UrlDecode(context.Request.QueryString["url"]);
}

public bool IsReusable
{
get
{
return false;
}
}
}


url parameter is like this:



http://server1.com/service?method=get&request=GetInfo
http://server1.com/service?method=get&request=GetFeatures
http://server1.com/service?method=get&request=GetImage&Format=PNG


I am parsing url querystring. Because some users can use method=get and can not use method=post. Some users can use request=GetInfo and some users can not use reguest=GetImage.


These are my rules by users. I want to use desgin pattern to implement these rules. But I could not decide to use. Specification, Strategy, or else. I am new at desing patterns.



public interface IRule{}
public class UserCanUseGetMethod:IRule{}


How can I combine rules and user?


Aucun commentaire:

Enregistrer un commentaire